#include <stdio.h>
#include <time.h>
#include <math.h>
#include <sys/time.h>
int frequency_of_primes |
( |
int |
n | ) |
|
39 for (i=2; i<=n; ++i) for (j=(int)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 |
|
) |
| |
46 if (
x->tv_usec <
y->tv_usec) {
47 int nsec = (
y->tv_usec -
x->tv_usec) / 1000000 + 1;
48 y->tv_usec -= 1000000 * nsec;
51 if (
x->tv_usec -
y->tv_usec > 1000000) {
52 int nsec = (
y->tv_usec -
x->tv_usec) / 1000000;
53 y->tv_usec += 1000000 * nsec;
59 result->tv_sec =
x->tv_sec -
y->tv_sec;
60 result->tv_usec =
x->tv_usec -
y->tv_usec;
63 return x->tv_sec <
y->tv_sec;
float elapsed_time |
( |
struct timeval |
dif, |
|
|
struct timeval |
a, |
|
|
struct timeval |
b |
|
) |
| |
72 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: playground/clock_test.cpp:43
Definition: eci2kep_test.cpp:33
79 printf (
"Calculating...\n");
81 struct timeval tv1,tv2,diff;
89 gettimeofday(&tv1, &tz);
91 gettimeofday(&tv2, &tz);
95 tm=localtime(&tv1.tv_sec);
96 printf(
" %d:%02d:%02d %d \n", (
int)tm->tm_hour, (
int)tm->tm_min, (
int)tm->tm_sec, (
int)tv1.tv_usec);
98 tm=localtime(&tv2.tv_sec);
99 printf(
" %d:%02d:%02d %d \n", (
int)tm->tm_hour, (
int)tm->tm_min, (
int)tm->tm_sec, (
int)tv2.tv_usec);
105 printf(
"It took me %f milliseconds\n", k);
110 printf (
"The number of primes lower than 100,000 is: %d\n",f);
111 printf (
"It took me %d clicks (%f seconds). CPS: %f\n",dt,dt/(
double)CLOCKS_PER_SEC,(
double)CLOCKS_PER_SEC);
115 time_t now = time(0);
119 seconds = time (&now);
120 printf (
"%ld hours since January 1, 1970\n", seconds/3600);
ElapsedTime dt
Definition: agent_file3.cpp:183
int frequency_of_primes(int n)
Definition: playground/clock_test.cpp:36
float elapsed_time(struct timeval dif, struct timeval a, struct timeval b)
Definition: playground/clock_test.cpp:66