Add bench_duration function
This commit is contained in:
parent
c421bea11f
commit
3121937da5
3 changed files with 11 additions and 3 deletions
|
@ -45,12 +45,16 @@ void bench_stop(bench *b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double bench_iteration_speed(bench *b) {
|
double bench_iteration_speed(bench *b) {
|
||||||
return b->N / (b->end - b->start);
|
return (b->N * b->R) / (b->end - b->start);
|
||||||
|
}
|
||||||
|
|
||||||
|
double bench_duration(bench *b) {
|
||||||
|
return (b->end - b->start);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bench_print_summary(bench *b) {
|
void bench_print_summary(bench *b) {
|
||||||
printf("%ld runs, ", b->R);
|
printf("%ld runs, ", b->R);
|
||||||
printf("%ld iterations each run, ", b->N);
|
printf("%ld iterations each run, ", b->N);
|
||||||
printf("finished in %lf seconds\n", b->end - b->start );
|
printf("finished in %lf seconds\n", bench_duration(b) );
|
||||||
printf("%.2f i/sec\n", (b->N * b->R) / (b->end - b->start) );
|
printf("%.2f i/sec\n", bench_iteration_speed(b) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ double bench_iteration_speed(bench *b);
|
||||||
|
|
||||||
void bench_print_summary(bench *b);
|
void bench_print_summary(bench *b);
|
||||||
|
|
||||||
|
double bench_duration(bench *b);
|
||||||
|
|
||||||
#define BENCHMARK(B) \
|
#define BENCHMARK(B) \
|
||||||
bench B; B.N = 5000000; B.R = 3; \
|
bench B; B.N = 5000000; B.R = 3; \
|
||||||
bench_start(&B); \
|
bench_start(&B); \
|
||||||
|
|
|
@ -449,3 +449,5 @@
|
||||||
1400748826,12902583.84
|
1400748826,12902583.84
|
||||||
1400748965,13584323.91
|
1400748965,13584323.91
|
||||||
1400749175,13518288.33
|
1400749175,13518288.33
|
||||||
|
1400749320,13445606.30
|
||||||
|
1400749326,13242705.99
|
||||||
|
|
|
Loading…
Reference in a new issue