benchmark.h (619B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#ifndef _BENCHMARK_H_
#define _BENCHMARK_H_
#include "intrinsics.h"
struct ScopedTimer {
u64 initial_clock;
u32 timer_idx;
ScopedTimer( u32 idx );
~ScopedTimer();
};
u32 benchmark_new_timer( const char * fn, const char * file, int line );
void benchmark_print_timers();
// TODO: i think this works but double check to make sure it really does.
#define TIMED_BLOCK( fn, file, line ) \
static u32 benchmark_timer_idx = benchmark_new_timer( fn, file, line ); \
ScopedTimer benchmark_timer( benchmark_timer_idx );
#define TIMED_FUNCTION() TIMED_BLOCK( __FUNCTION__, __FILE__, __LINE__ )
#endif // _BENCHMARK_H_
|