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