summaryrefslogtreecommitdiff
path: root/benchmarks/stdio_benchmark.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-12-12 00:29:22 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-12-12 00:29:22 +0000
commiteb7347aedbc61ba45555aef3e6e863f0d90b407b (patch)
tree15e60803da99f7b6802a90885fa60e1b5ee2ba41 /benchmarks/stdio_benchmark.cpp
parent4940a24a1146f3a3f03925ebc1b090028e42e49f (diff)
parent3b644e932a9a1e9f08ce27002c9a2803d5d74ef6 (diff)
Merge "Trivial scanf benchmarks."
Diffstat (limited to 'benchmarks/stdio_benchmark.cpp')
-rw-r--r--benchmarks/stdio_benchmark.cpp31
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);