]> 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 7dfac43805a6eb79ba8c8e28493afb43e7cc4796..cf2556bd2fc5ee87f85d2eac09d62d48e46e5955 100644 (file)
@@ -3,9 +3,8 @@
 #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].
@@ -93,18 +92,20 @@ void test_performance(idct_func_t* idct)
        uint8_t output[DCTSIZE2];
                
        gen_random_coeffs(coeff, DCTSIZE2);
+       
+       // Unit quantization (ie., no scaling).
+       for (unsigned i = 0; i < DCTSIZE2; ++i) {
+               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);
        }
        
-       gettimeofday(&now, NULL);
-
-       double diff = timediff(&start, &now);
-       printf("%u runs in %.2f seconds = %.2f DCTs/sec\n",
+       double diff = stop_benchmark_timer();
+       printf("%u runs in %.2f CPU seconds = %.2f IDCTs/sec\n",
                num_runs, diff, num_runs / diff);
 }
 
@@ -125,6 +126,9 @@ int main(void)
        printf("idct_reference:\n");
        test_all_idct(idct_reference);
 
+       printf("idct_float:\n");
+       test_all_idct(idct_float);
+
        printf("All tests pass.\n");
        return 0;
 }