15 #ifndef MOTIVE_UTIL_BENCHMARK_H_
16 #define MOTIVE_UTIL_BENCHMARK_H_
20 #define FPL_TOKEN_PASTE_NESTED(a, b) a##b
21 #define FPL_TOKEN_PASTE(a, b) FPL_TOKEN_PASTE_NESTED(a, b)
22 #define FPL_UNIQUE(token) FPL_TOKEN_PASTE(token, __LINE__)
24 #if defined(BENCHMARK_MOTIVE)
27 typedef unsigned long long BenchmarkTime;
30 BenchmarkTime GetBenchmarkTime();
35 void InitBenchmarks(
int num_ids);
38 void ClearBenchmarks();
42 int RegisterBenchmark(
const char* name);
45 void OutputBenchmarks();
55 explicit Benchmark(
int id) : id_(
id), start_time_(GetBenchmarkTime()) {}
59 BenchmarkTime start_time_;
62 #define FPL_BENCHMARK(name) \
63 static int FPL_UNIQUE(id) = fplbase::RegisterBenchmark(name); \
64 const fplbase::Benchmark FPL_UNIQUE(benchmark)(FPL_UNIQUE(id))
66 #else // not defined(BENCHMARK_MOTIVE)
69 inline void InitBenchmarks(
int ) {}
70 inline void ClearBenchmarks() {}
71 inline int RegisterBenchmark(
const char* ) {
return -1; }
72 inline void OutputBenchmarks() {}
75 explicit Benchmark(
int ) {}
78 #define FPL_BENCHMARK(name)
80 #endif // not defined(BENCHMARK_MOTIVE)
85 #endif // MOTIVE_UTIL_BENCHMARK_H_
Record the time for the scope of this variable.
Definition: benchmark.h:53