Arcane
v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
PerfCounterMng.cc
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
//-----------------------------------------------------------------------------
3
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4
// See the top-level COPYRIGHT file for details.
5
// SPDX-License-Identifier: Apache-2.0
6
//-----------------------------------------------------------------------------
7
/*---------------------------------------------------------------------------*/
8
/* PerfCounterMng.cc (C) 2000-2017 */
9
/* */
10
/* */
11
/*---------------------------------------------------------------------------*/
12
/*---------------------------------------------------------------------------*/
13
14
#include "arcane/utils/ArcanePrecomp.h"
15
#include "arcane/utils/PerfCounterMng.h"
16
17
#include <iostream>
18
19
/*---------------------------------------------------------------------------*/
20
/*---------------------------------------------------------------------------*/
21
22
ARCANE_BEGIN_NAMESPACE
23
24
/*---------------------------------------------------------------------------*/
25
/*---------------------------------------------------------------------------*/
26
27
/*!
28
* \brief Retourne la fréquence du CPU en Mhz.
29
*
30
* Ne marche que sous Linux et ne tient pas compte des variations
31
* possibles de fréquence telles que le turbo-boost.
32
*/
33
extern
"C++"
int
34
arcaneGetCpuBaseFrequency
()
35
{
36
#ifndef WIN32
37
/* return cpu frequency in MHZ as read in /proc/cpuinfo */
38
float
ffreq = 0;
39
int
r = 0;
40
char
*rr = NULL;
41
FILE *fdes = fopen(
"/proc/cpuinfo"
,
"r"
);
42
char
buff[256];
43
int
bufflength = 256;
44
do
{
45
rr = fgets(buff,bufflength,fdes);
46
r = sscanf(buff,
"cpu MHz : %f\n"
,&ffreq);
47
if
(r==1){
48
break
;
49
}
50
}
while
(rr != NULL);
51
52
fclose(fdes);
53
54
int
ifreq = (int)ffreq;
55
return
ifreq;
56
#else
57
std::cerr <<
"getCpuFreq not functionnal under win\n"
;
58
return
1;
59
#endif
60
}
61
62
/*---------------------------------------------------------------------------*/
63
/*---------------------------------------------------------------------------*/
64
65
ARCANE_END_NAMESPACE
66
67
/*---------------------------------------------------------------------------*/
68
/*---------------------------------------------------------------------------*/
69
Arcane::arcaneGetCpuBaseFrequency
int arcaneGetCpuBaseFrequency()
Retourne la fréquence du CPU en Mhz.
Definition
PerfCounterMng.cc:34
arcane
utils
PerfCounterMng.cc
Généré le Lundi 18 Novembre 2024 02:56:56 pour Arcane par
1.9.8