]> git.sesse.net Git - fjl/blobdiff - idct_test.c
Measure CPU seconds instead of wall time, and move the timing functions into a
[fjl] / idct_test.c
index e35a17b1b760edbe8ea104ea239abef5160ab7d4..cf2556bd2fc5ee87f85d2eac09d62d48e46e5955 100644 (file)
@@ -3,9 +3,8 @@
 #include <stdlib.h>
 #include <math.h>
 #include <assert.h>
 #include <stdlib.h>
 #include <math.h>
 #include <assert.h>
-#include <time.h>
-#include <sys/time.h>
 
 
+#include "benchmark.h"
 #include "idct.h"
 
 // Generate random coefficients in the range [-15..15].
 #include "idct.h"
 
 // Generate random coefficients in the range [-15..15].
@@ -99,17 +98,14 @@ void test_performance(idct_func_t* idct)
                quant[i] = 1;
        }
 
                quant[i] = 1;
        }
 
-       struct timeval start, now;
-       gettimeofday(&start, NULL);
+       start_benchmark_timer();
 
        for (unsigned i = 0; i < num_runs; ++i) {
                (*idct)(coeff, quant, output);
        }
        
 
        for (unsigned i = 0; i < num_runs; ++i) {
                (*idct)(coeff, quant, output);
        }
        
-       gettimeofday(&now, NULL);
-
-       double diff = timediff(&start, &now);
-       printf("%u runs in %.2f seconds = %.2f IDCTs/sec\n",
+       double diff = stop_benchmark_timer();
+       printf("%u runs in %.2f CPU seconds = %.2f IDCTs/sec\n",
                num_runs, diff, num_runs / diff);
 }
 
                num_runs, diff, num_runs / diff);
 }