Ensure low-memory renderers retry failed loads correctly.
[chromium-blink-merge.git] / third_party / re2 / util / benchmark.h
blob31bbd5348aee9bb86bfa521ca5cb5a5f51b8ba80
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__
8 namespace testing {
9 struct Benchmark {
10 const char* name;
11 void (*fn)(int);
12 void (*fnr)(int, int);
13 int lo;
14 int hi;
15 int threadlo;
16 int threadhi;
18 void Register();
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);
32 int NumCPUs();
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__