#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].
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);
}
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;
}