summaryrefslogtreecommitdiff
path: root/benchmarks/stdio_benchmark.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-08-23 15:55:28 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-08-23 15:55:28 +0000
commit57e07a150e536f79d78f8203b0c807087b5c854b (patch)
tree0fa9d4957221655de00bb2b385bba2267a431346 /benchmarks/stdio_benchmark.cpp
parent96ba713f7336c1c21dacee8a4add72a47cdd826c (diff)
parentd706fe5f9e83707901389914c77afa69c19e07e6 (diff)
Merge "Fix the stdio fwrite benchmark."
Diffstat (limited to 'benchmarks/stdio_benchmark.cpp')
-rw-r--r--benchmarks/stdio_benchmark.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp
index 2ab7264a0..3f5e0f138 100644
--- a/benchmarks/stdio_benchmark.cpp
+++ b/benchmarks/stdio_benchmark.cpp
@@ -26,7 +26,7 @@ template <typename Fn>
void ReadWriteTest(benchmark::State& state, Fn f, bool buffered) {
size_t chunk_size = state.range(0);
- FILE* fp = fopen("/dev/zero", "rw");
+ FILE* fp = fopen("/dev/zero", "r+e");
__fsetlocking(fp, FSETLOCKING_BYCALLER);
char* buf = new char[chunk_size];
@@ -35,7 +35,9 @@ void ReadWriteTest(benchmark::State& state, Fn f, bool buffered) {
}
while (state.KeepRunning()) {
- f(buf, chunk_size, 1, fp);
+ if (f(buf, chunk_size, 1, fp) != 1) {
+ errx(1, "ERROR: op of %zu bytes failed.", chunk_size);
+ }
}
state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(chunk_size));
@@ -70,7 +72,7 @@ static void FopenFgetsFclose(benchmark::State& state, bool no_locking) {
FILE* fp = fopen("/dev/zero", "re");
if (no_locking) __fsetlocking(fp, FSETLOCKING_BYCALLER);
if (fgets(buf, sizeof(buf), fp) == nullptr) {
- errx(1, "ERROR: fgets of %zu bytes failed.", nbytes);
+ errx(1, "ERROR: fgets of %zu bytes failed.", nbytes);
}
fclose(fp);
}
@@ -108,4 +110,3 @@ void BM_stdio_fopen_fgetc_fclose_no_locking(benchmark::State& state) {
FopenFgetcFclose(state, true);
}
BIONIC_BENCHMARK(BM_stdio_fopen_fgetc_fclose_no_locking);
-