1
0
mirror of https://github.com/google/benchmark.git synced 2025-04-29 06:20:32 +08:00

add to readme

This commit is contained in:
Eric Fiselier 2015-03-27 04:43:09 -04:00
parent fe49e609ab
commit f7d14e719b

View File

@ -160,6 +160,19 @@ static void BM_MultiThreaded(benchmark::State& state) {
}
}
BENCHMARK(BM_MultiThreaded)->Threads(2);
To prevent a value or expression from being optimized away by the compiler
the `benchmark::DoNotOptimize(...)` function can be used.
```c++
static void BM_test(benchmark::State& state) {
while (state.KeepRunning()) {
int x = 0;
for (int i=0; i < 64; ++i) {
benchmark::DoNotOptimize(x += i);
}
}
}
```