source:
doc/generic_types/evaluation/bench.h
@
4b0f997
Last change on this file since 4b0f997 was 47535a0d, checked in by , 7 years ago | |
---|---|
|
|
File size: 435 bytes |
Rev | Line | |
---|---|---|
[d919f47] | 1 | #pragma once |
2 | ||
[309be81] | 3 | #include <stdio.h> |
4 | #include <time.h> | |
5 | ||
[47535a0d] | 6 | #define N 100000000 |
[309be81] | 7 | |
8 | long ms_between(clock_t start, clock_t end) { | |
9 | return (end - start) / (CLOCKS_PER_SEC / 1000); | |
10 | } | |
11 | ||
12 | #define TIMED(name, code) { \ | |
[b276be5] | 13 | volatile clock_t _start, _end; \ |
[d919f47] | 14 | _start = clock(); \ |
[309be81] | 15 | code \ |
[d919f47] | 16 | _end = clock(); \ |
[47535a0d] | 17 | printf("%s:\t%8ld ms\n", name, ms_between(_start, _end)); \ |
[309be81] | 18 | } |
19 | ||
[d919f47] | 20 | #define REPEAT_TIMED(name, code) TIMED( name, for (int _i = 0; _i < N; ++_i) { code } ) |
Note: See TracBrowser
for help on using the repository browser.