aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-12-11 14:43:52 -0800
committerElliott Hughes <enh@google.com>2017-12-11 14:46:22 -0800
commit3b644e932a9a1e9f08ce27002c9a2803d5d74ef6 (patch)
tree15e60803da99f7b6802a90885fa60e1b5ee2ba41 /benchmarks
parent4940a24a1146f3a3f03925ebc1b090028e42e49f (diff)
downloadandroid_bionic-3b644e932a9a1e9f08ce27002c9a2803d5d74ef6.tar.gz
android_bionic-3b644e932a9a1e9f08ce27002c9a2803d5d74ef6.tar.bz2
android_bionic-3b644e932a9a1e9f08ce27002c9a2803d5d74ef6.zip
Trivial scanf benchmarks.
Bug: http://b/68672236 Test: ran benchmarks Change-Id: I96514be5e67969b65205e953051c524be3626ec4
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/stdio_benchmark.cpp31
-rw-r--r--benchmarks/tests/interface_test.cpp3
2 files changed, 34 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);
diff --git a/benchmarks/tests/interface_test.cpp b/benchmarks/tests/interface_test.cpp
index 3020c270e..64629e688 100644
--- a/benchmarks/tests/interface_test.cpp
+++ b/benchmarks/tests/interface_test.cpp
@@ -298,6 +298,9 @@ TEST_F(SystemTests, all_benchmarks) {
"BM_stdio_printf_d/iterations:1\n"
"BM_stdio_printf_literal/iterations:1\n"
"BM_stdio_printf_s/iterations:1\n"
+ "BM_stdio_scanf_d/iterations:1\n"
+ "BM_stdio_scanf_maps/iterations:1\n"
+ "BM_stdio_scanf_s/iterations:1\n"
"BM_stdlib_malloc_free/8/iterations:1\n"
"BM_stdlib_malloc_free/64/iterations:1\n"
"BM_stdlib_malloc_free/512/iterations:1\n"