summaryrefslogtreecommitdiff
path: root/benchmarks/stdio_benchmark.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-10-22 13:43:59 -0700
committerElliott Hughes <enh@google.com>2020-10-22 13:43:59 -0700
commite8693e78711e8f45ccd2b610e4dbe0b94d551cc9 (patch)
tree5b7a67244a6a122e27fca20f84d0a4f78d487fe2 /benchmarks/stdio_benchmark.cpp
parent9aa6b15d799ac246e842552fca555920a93ce46b (diff)
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
Diffstat (limited to 'benchmarks/stdio_benchmark.cpp')
-rw-r--r--benchmarks/stdio_benchmark.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp
index 037bbd911..03f3f2903 100644
--- a/benchmarks/stdio_benchmark.cpp
+++ b/benchmarks/stdio_benchmark.cpp
@@ -155,9 +155,8 @@ static void FopenFgetcFclose(benchmark::State& state, bool no_locking) {
while (state.KeepRunning()) {
FILE* fp = fopen("/dev/zero", "re");
if (no_locking) __fsetlocking(fp, FSETLOCKING_BYCALLER);
- volatile int c __attribute__((unused));
for (size_t i = 0; i < nbytes; ++i) {
- c = fgetc(fp);
+ benchmark::DoNotOptimize(fgetc(fp));
}
fclose(fp);
}