diff options
author | Elliott Hughes <enh@google.com> | 2017-12-11 14:43:52 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2017-12-11 14:46:22 -0800 |
commit | 3b644e932a9a1e9f08ce27002c9a2803d5d74ef6 (patch) | |
tree | 15e60803da99f7b6802a90885fa60e1b5ee2ba41 /benchmarks/stdio_benchmark.cpp | |
parent | 4940a24a1146f3a3f03925ebc1b090028e42e49f (diff) |
Trivial scanf benchmarks.
Bug: http://b/68672236
Test: ran benchmarks
Change-Id: I96514be5e67969b65205e953051c524be3626ec4
Diffstat (limited to 'benchmarks/stdio_benchmark.cpp')
-rw-r--r-- | benchmarks/stdio_benchmark.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp index d547fedec..872725d34 100644 --- a/benchmarks/stdio_benchmark.cpp +++ b/benchmarks/stdio_benchmark.cpp @@ -15,6 +15,7 @@ */ #include <err.h> +#include <inttypes.h> #include <stdio.h> #include <stdio_ext.h> #include <stdlib.h> @@ -205,3 +206,33 @@ static void BM_stdio_printf_1$s(benchmark::State& state) { } } BIONIC_BENCHMARK(BM_stdio_printf_1$s); + +static void BM_stdio_scanf_s(benchmark::State& state) { + while (state.KeepRunning()) { + char s[BUFSIZ]; + if (sscanf("file /etc/passwd", "file %s", s) != 1) abort(); + } +} +BIONIC_BENCHMARK(BM_stdio_scanf_s); + +static void BM_stdio_scanf_d(benchmark::State& state) { + while (state.KeepRunning()) { + int i; + if (sscanf("size 12345", "size %d", &i) != 1) abort(); + } +} +BIONIC_BENCHMARK(BM_stdio_scanf_d); + +static void BM_stdio_scanf_maps(benchmark::State& state) { + while (state.KeepRunning()) { + uintptr_t start; + uintptr_t end; + uintptr_t offset; + char permissions[5]; + int name_pos; + if (sscanf("6f000000-6f01e000 rwxp 00000000 00:0c 16389419 /system/lib/libcomposer.so", + "%" PRIxPTR "-%" PRIxPTR " %4s %" PRIxPTR " %*x:%*x %*d %n", + &start, &end, permissions, &offset, &name_pos) != 4) abort(); + } +} +BIONIC_BENCHMARK(BM_stdio_scanf_maps); |