source: doc/generic_types/evaluation/bench.hpp @ 2183e12

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 2183e12 was a381b46, checked in by Aaron Moss <a3moss@…>, 7 years ago

Minor cleanup, also filled in benchmark source appendix

  • Property mode set to 100644
File size: 586 bytes
RevLine 
[b276be5]1#pragma once
2#include <iomanip>
3#include <iostream>
4#include <time.h>
5
[a381b46]6long ms_between(clock_t start, clock_t end) { return (end - start) / (CLOCKS_PER_SEC / 1000); }
[b276be5]7
[a381b46]8static const int N = 40000000;
[b276be5]9#define TIMED(name, code) { \
10        volatile clock_t _start, _end; \
11        _start = clock(); \
12        code \
13        _end = clock(); \
[a381b46]14        std::cout << name << ":\t" << std::setw(8) << ms_between(_start, _end) \
15                << std::setw(0) << " ms" << std::endl; \
[b276be5]16}
[3fb7f5e]17#define REPEAT_N_TIMED(name, n, code) TIMED( name, for (int _i = 0; _i < n; ++_i) { code } )
18#define REPEAT_TIMED(name, code) REPEAT_N_TIMED(name, N, code)
Note: See TracBrowser for help on using the repository browser.