diff options
author | Elliott Hughes <enh@google.com> | 2017-10-26 15:41:49 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2017-10-26 15:43:34 -0700 |
commit | 928059907bb5d594472687d1d05266158d317bb8 (patch) | |
tree | afafcf66e8c2f9cc80a01643ae20cfd7f88d95ad /benchmarks | |
parent | c6291b081d2089ba7a16d7777fb2713d828d537f (diff) | |
download | android_bionic-928059907bb5d594472687d1d05266158d317bb8.tar.gz android_bionic-928059907bb5d594472687d1d05266158d317bb8.tar.bz2 android_bionic-928059907bb5d594472687d1d05266158d317bb8.zip |
Add basic printf benchmarks.
Bug: http://b/67371539
Test: ran benchmarks
Change-Id: I6ad05540079776b2df4cc8d9c02440c61e42037d
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/stdio_benchmark.cpp | 25 | ||||
-rw-r--r-- | benchmarks/suites/full.xml | 9 |
2 files changed, 34 insertions, 0 deletions
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp index 0e7f668f3..97a03dc32 100644 --- a/benchmarks/stdio_benchmark.cpp +++ b/benchmarks/stdio_benchmark.cpp @@ -171,3 +171,28 @@ void BM_stdio_fopen_fgetc_fclose_no_locking(benchmark::State& state) { FopenFgetcFclose(state, true); } BIONIC_BENCHMARK(BM_stdio_fopen_fgetc_fclose_no_locking); + +static void BM_stdio_printf_literal(benchmark::State& state) { + while (state.KeepRunning()) { + char buf[BUFSIZ]; + snprintf(buf, sizeof(buf), "this is just a literal string with no format specifiers"); + } +} +BIONIC_BENCHMARK(BM_stdio_printf_literal); + +static void BM_stdio_printf_s(benchmark::State& state) { + while (state.KeepRunning()) { + char buf[BUFSIZ]; + snprintf(buf, sizeof(buf), "this is a more typical error message with detail: %s", + "No such file or directory"); + } +} +BIONIC_BENCHMARK(BM_stdio_printf_s); + +static void BM_stdio_printf_d(benchmark::State& state) { + while (state.KeepRunning()) { + char buf[BUFSIZ]; + snprintf(buf, sizeof(buf), "this is a more typical error message with detail: %d", 123456); + } +} +BIONIC_BENCHMARK(BM_stdio_printf_d); diff --git a/benchmarks/suites/full.xml b/benchmarks/suites/full.xml index a7bd9d468..240b5e79a 100644 --- a/benchmarks/suites/full.xml +++ b/benchmarks/suites/full.xml @@ -189,6 +189,15 @@ <name>BM_stdio_fopen_getline_fclose_no_locking</name> </fn> <fn> + <name>BM_stdio_printf_literal</name> +</fn> +<fn> + <name>BM_stdio_printf_s</name> +</fn> +<fn> + <name>BM_stdio_printf_d</name> +</fn> +<fn> <name>BM_string_memcmp</name> <args>AT_ALIGNED_TWOBUF</args> </fn> |