#include
#include
int main()
{
double x,y;
long i;
x = 1/3.1415692653;
for(i=0; i<1000000; i++) {
y = i/100000*x;
printf("%lu) sin(%lf) = %lf\n", i, y, sin(y));
}
}
Compile it with:
gcc -mtune=nocona -m64 -msse3 -mfpmath=sse -O3 sin.c -o sin
and execute is as below:
time ./sin
The result is:
real 0m12.345s
user 0m2.624s
sys 0m3.554s
The "real" gives result 12.345 seconds to do 1E6 iterations!, or for each iteration it'd take 12.345E-6 second (12.345 microseconds). Wow!
No comments:
Post a Comment