#include <stdio.h>
#include <time.h>
#include <math.h>
#include <sys/time.h>
int frequency_of_primes |
( |
int |
n | ) |
|
38 for (i=2; i<=n; ++i) for (j=sqrt(i);j>1;--j)
if (i%j==0) {--
freq;
break;}
int i
Definition: rw_test.cpp:37
JHUFF_TBL long freq[]
Definition: jchuff.h:47
int timeval_subtract |
( |
struct timeval * |
result, |
|
|
struct timeval * |
x, |
|
|
struct timeval * |
y |
|
) |
| |
45 if (
x->tv_usec <
y->tv_usec) {
46 int nsec = (
y->tv_usec -
x->tv_usec) / 1000000 + 1;
47 y->tv_usec -= 1000000 * nsec;
50 if (
x->tv_usec -
y->tv_usec > 1000000) {
51 int nsec = (
y->tv_usec -
x->tv_usec) / 1000000;
52 y->tv_usec += 1000000 * nsec;
58 result->tv_sec =
x->tv_sec -
y->tv_sec;
59 result->tv_usec =
x->tv_usec -
y->tv_usec;
62 return x->tv_sec <
y->tv_sec;
float elapsed_time |
( |
struct timeval |
dif, |
|
|
struct timeval |
a, |
|
|
struct timeval |
b |
|
) |
| |
71 return -dif.tv_sec*1000.0-dif.tv_usec/1000.0;
long b
Definition: jpegint.h:371
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
Definition: old/sensors/imu_microstrain/clock_test.cpp:42
Definition: eci2kep_test.cpp:33
78 printf (
"Calculating...\n");
81 struct itimerval *ov=NULL;
83 struct timeval tv1,tv2,diff;
91 gettimeofday(&tv1, &tz);
93 gettimeofday(&tv2, &tz);
97 tm=localtime(&tv1.tv_sec);
98 printf(
" %d:%02d:%02d %d \n", tm->tm_hour, tm->tm_min,
99 tm->tm_sec, tv1.tv_usec);
101 tm=localtime(&tv2.tv_sec);
102 printf(
" %d:%02d:%02d %d \n", tm->tm_hour, tm->tm_min,
103 tm->tm_sec, tv2.tv_usec);
109 printf(
"It took me %f milliseconds\n", k);
114 printf (
"The number of primes lower than 100,000 is: %d\n",f);
115 printf (
"It took me %d clicks (%f seconds). CPS: %ld\n",dt,dt/(
double)CLOCKS_PER_SEC,(
double)CLOCKS_PER_SEC);
119 time_t now = time(0);
123 seconds = time (&now);
124 printf (
"%ld hours since January 1, 1970\n", seconds/3600);
127 }
ElapsedTime dt
Definition: agent_file3.cpp:183
float elapsed_time(struct timeval dif, struct timeval a, struct timeval b)
Definition: old/sensors/imu_microstrain/clock_test.cpp:65
int frequency_of_primes(int n)
Definition: old/sensors/imu_microstrain/clock_test.cpp:35