source: doc/generic_types/evaluation/bench.hpp @ d9dd3d1

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since d9dd3d1 was 0d10090, checked in by Aaron Moss <a3moss@…>, 5 years ago

Add printing code to benchmark

  • Property mode set to 100644
File size: 535 bytes
Line 
1#pragma once
2
3#include <iomanip>
4#include <iostream>
5#include <time.h>
6
7#ifndef N
8static const int N = 40000000;
9#endif
10
11long ms_between(clock_t start, clock_t end) {
12        return (end - start) / (CLOCKS_PER_SEC / 1000);
13}
14
15#define TIMED(name, code) { \
16        volatile clock_t _start, _end; \
17        _start = clock(); \
18        code \
19        _end = clock(); \
20        std::cout << name << ":\t" << std::setw(8) << ms_between(_start, _end) << std::setw(0) << " ms" << std::endl; \
21}
22
23#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.