/* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file ./src/test_speed.c * \brief « brief description » * \ingroup « module » * * « long description » */ #include "common/std.h" #include "sys/time.h" #include "stdio.h" #include "string.h" #include "math.h" int main (int argc, char **argv) { struct timeval tv0, tv1; double test_d; int r; double flottant = 0.123456789; double res = flottant; double x=0; gettimeofday (&tv0, NULL); for (r=-10000; r<10000; r++) { x = (double)(M_PI*r)/ 10000.0; for (test_d=0; test_d<100; test_d++) { res = test_d * x; } } gettimeofday (&tv1, NULL); printf ("test duration [mux] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); gettimeofday (&tv0, NULL); for (r=-10000; r<10000; r++) { x = (double)(M_PI*r)/ 10000.0; for (test_d=0; test_d<100; test_d++) { res = test_d / x; } } gettimeofday (&tv1, NULL); printf ("test duration [div : dble/dble] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); gettimeofday (&tv0, NULL); for (r=-10000; r<10000; r++) { x = (double)(M_PI*r)/ 10000.0; for (test_d=0; test_d<100; test_d++) { res = sin (x); } } gettimeofday (&tv1, NULL); printf ("test duration [sin (dble)] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); return 0; }