1 // Copyright 2009 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 #ifndef RE2_UTIL_BENCHMARK_H__
6 #define RE2_UTIL_BENCHMARK_H__
12 void (*fnr
)(int, int);
19 Benchmark(const char* name
, void (*f
)(int)) { Clear(name
); fn
= f
; Register(); }
20 Benchmark(const char* name
, void (*f
)(int, int), int l
, int h
) { Clear(name
); fnr
= f
; lo
= l
; hi
= h
; Register(); }
21 void Clear(const char* n
) { name
= n
; fn
= 0; fnr
= 0; lo
= 0; hi
= 0; threadlo
= 0; threadhi
= 0; }
22 Benchmark
* ThreadRange(int lo
, int hi
) { threadlo
= lo
; threadhi
= hi
; return this; }
24 } // namespace testing
26 void SetBenchmarkBytesProcessed(long long);
27 void StopBenchmarkTiming();
28 void StartBenchmarkTiming();
29 void BenchmarkMemoryUsage();
30 void SetBenchmarkItemsProcessed(int);
34 #define BENCHMARK(f) \
35 ::testing::Benchmark* _benchmark_##f = (new ::testing::Benchmark(#f, f))
37 #define BENCHMARK_RANGE(f, lo, hi) \
38 ::testing::Benchmark* _benchmark_##f = \
39 (new ::testing::Benchmark(#f, f, lo, hi))
41 #endif // RE2_UTIL_BENCHMARK_H__