Add 'benchmark::DoNotOptimize(...)' to help users prevent optimizations
diff --git a/README.md b/README.md
index 553e34a..4c0d77a 100644
--- a/README.md
+++ b/README.md
@@ -160,6 +160,19 @@
}
}
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);
+ }
+ }
+}
```