source:
doc/generic_types/evaluation/bench.h
@
0111dc7
Last change on this file since 0111dc7 was 0d10090, checked in by , 7 years ago | |
---|---|
|
|
File size: 451 bytes |
Rev | Line | |
---|---|---|
[d919f47] | 1 | #pragma once |
2 | ||
[309be81] | 3 | #include <stdio.h> |
4 | #include <time.h> | |
5 | ||
[0d10090] | 6 | #ifndef N |
7 | #define N 40000000 | |
8 | #endif | |
[309be81] | 9 | |
10 | long ms_between(clock_t start, clock_t end) { | |
11 | return (end - start) / (CLOCKS_PER_SEC / 1000); | |
12 | } | |
13 | ||
14 | #define TIMED(name, code) { \ | |
[b276be5] | 15 | volatile clock_t _start, _end; \ |
[d919f47] | 16 | _start = clock(); \ |
[309be81] | 17 | code \ |
[d919f47] | 18 | _end = clock(); \ |
[47535a0d] | 19 | printf("%s:\t%8ld ms\n", name, ms_between(_start, _end)); \ |
[309be81] | 20 | } |
21 | ||
[d919f47] | 22 | #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.