summaryrefslogtreecommitdiff
path: root/benchmarks/stdio_benchmark.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-11-03 14:00:37 -0700
committerElliott Hughes <enh@google.com>2017-11-03 14:19:00 -0700
commit5305a4d4a723b06494b93f2df81733b83a0c46d3 (patch)
treee2de767071618925487ca8b8ba2da4d7aac62fce /benchmarks/stdio_benchmark.cpp
parent232541aa02e22ab8fafcdd503c74aae22fa09699 (diff)
10x printf speedup.
Android is UTF-8. Don't make everyone pay to convert UTF-8 to ASCII just so we can recognize '%'. With UTF-8 we can just strchr forwards. Before: --------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------- BM_stdio_printf_literal 1290 ns 1290 ns 442554 BM_stdio_printf_s 1204 ns 1204 ns 582446 BM_stdio_printf_d 1206 ns 1206 ns 578311 BM_stdio_printf_1$s 2263 ns 2263 ns 310002 After: --------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------- BM_stdio_printf_literal 178 ns 178 ns 3394001 BM_stdio_printf_s 246 ns 246 ns 2850284 BM_stdio_printf_d 252 ns 252 ns 2778610 BM_stdio_printf_1$s 363 ns 363 ns 1929011 Add missing __find_arguments error checking to the wide variant to match the regular one. Also replace various char/wchar_t differences with the macro. Bug: http://b/67371539 Test: ran tests Change-Id: I18f122009c22699943ab5d666a98ea594a972c40
Diffstat (limited to 'benchmarks/stdio_benchmark.cpp')
-rw-r--r--benchmarks/stdio_benchmark.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp
index 97a03dc32..76e9ddb13 100644
--- a/benchmarks/stdio_benchmark.cpp
+++ b/benchmarks/stdio_benchmark.cpp
@@ -196,3 +196,12 @@ static void BM_stdio_printf_d(benchmark::State& state) {
}
}
BIONIC_BENCHMARK(BM_stdio_printf_d);
+
+static void BM_stdio_printf_1$s(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ char buf[BUFSIZ];
+ snprintf(buf, sizeof(buf), "this is a more typical error message with detail: %1$s",
+ "No such file or directory");
+ }
+}
+BIONIC_BENCHMARK(BM_stdio_printf_1$s);