Make more use of benchmark::DoNotOptimize in benchmarks.
A lot of these benchmarks predate DoNotOptimize and rolled their own
hacks.
Bug: http://b/148307629
Test: ran benchmarks before & after and got similar results
Change-Id: If44699d261b687f6253af709edda58f4c90fb285
diff --git a/benchmarks/stdlib_benchmark.cpp b/benchmarks/stdlib_benchmark.cpp
index 45b953f..b6ea58d 100644
--- a/benchmarks/stdlib_benchmark.cpp
+++ b/benchmarks/stdlib_benchmark.cpp
@@ -189,9 +189,8 @@
buf[l++] = i, buf[l++] = j, buf[l++] = 0x80, buf[l++] = k;
buf[l++] = 0;
- volatile size_t c __attribute__((unused)) = 0;
for (auto _ : state) {
- c = mbstowcs(widebuf_aligned, buf_aligned, 500000);
+ benchmark::DoNotOptimize(mbstowcs(widebuf_aligned, buf_aligned, 500000));
}
state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(500000));