diff options
Diffstat (limited to 'nacl/cpucycles/sgi.c')
-rw-r--r-- | nacl/cpucycles/sgi.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/nacl/cpucycles/sgi.c b/nacl/cpucycles/sgi.c deleted file mode 100644 index c232af09..00000000 --- a/nacl/cpucycles/sgi.c +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #include <time.h> | ||
2 | #include <stdio.h> | ||
3 | #include <unistd.h> | ||
4 | #include <sys/time.h> | ||
5 | #include <sys/types.h> | ||
6 | #include <sys/sysctl.h> | ||
7 | |||
8 | static double cpufrequency = 0; | ||
9 | |||
10 | static void init(void) | ||
11 | { | ||
12 | FILE *f; | ||
13 | |||
14 | f = popen("hinv -c processor | awk '{if ($3==\"MHZ\") print $2*1000000}'","r"); | ||
15 | if (!f) return; | ||
16 | if (fscanf(f,"%lf",&cpufrequency) < 1) cpufrequency = 0; | ||
17 | pclose(f); | ||
18 | if (!cpufrequency) return; | ||
19 | } | ||
20 | |||
21 | long long cpucycles_sgi(void) | ||
22 | { | ||
23 | double result; | ||
24 | struct timespec t; | ||
25 | if (!cpufrequency) init(); | ||
26 | clock_gettime(CLOCK_SGI_CYCLE,&t); | ||
27 | result = t.tv_nsec; | ||
28 | result *= 0.000000001; | ||
29 | result += (double) t.tv_sec; | ||
30 | result *= cpufrequency; | ||
31 | return result; | ||
32 | } | ||
33 | |||
34 | long long cpucycles_sgi_persecond(void) | ||
35 | { | ||
36 | if (!cpufrequency) init(); | ||
37 | return cpufrequency; | ||
38 | } | ||