summaryrefslogtreecommitdiff
path: root/benchmarks/stdlib_benchmark.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-12-19 08:55:40 -0800
committerElliott Hughes <enh@google.com>2017-12-19 08:55:40 -0800
commit7063a838be5eb1f28f40a554944a31bab49c3211 (patch)
tree6f498b51428018eac4a519f7624b9e8131433433 /benchmarks/stdlib_benchmark.cpp
parent721a5305e24b69b68ecc9431526f32131abc8f6c (diff)
More benchmarks.
Add a hand-rolled maps line parser as something to compare our realistic sscanf benchmark against. Also add benchmarks for the ato*/strto* family. This patch doesn't fix the tests, which seem to have been broken by the recent google-benchmark upgrade despite the benchmarks themselves all working just fine. To me that's a final strike against these tests which are hard to maintain and not obviously useful, but we can worry about what to do with them -- whether to just delete them or to try to turn them into tests that actually have some value -- in a separate CL. Bug: N/A Test: ran benchmarks Change-Id: I6c9a77ece98d624baeb049b360876ef5c35ea7f2
Diffstat (limited to 'benchmarks/stdlib_benchmark.cpp')
-rw-r--r--benchmarks/stdlib_benchmark.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/benchmarks/stdlib_benchmark.cpp b/benchmarks/stdlib_benchmark.cpp
index 0bee683e4..24773dea9 100644
--- a/benchmarks/stdlib_benchmark.cpp
+++ b/benchmarks/stdlib_benchmark.cpp
@@ -118,3 +118,45 @@ static void BM_stdlib_mbrtowc(benchmark::State& state) {
state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(500000));
}
BIONIC_BENCHMARK_WITH_ARG(BM_stdlib_mbrtowc, "0");
+
+void BM_stdlib_atoi(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ benchmark::DoNotOptimize(atoi(" -123"));
+ }
+}
+BIONIC_BENCHMARK(BM_stdlib_atoi);
+
+void BM_stdlib_atol(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ benchmark::DoNotOptimize(atol(" -123"));
+ }
+}
+BIONIC_BENCHMARK(BM_stdlib_atol);
+
+void BM_stdlib_strtol(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ benchmark::DoNotOptimize(strtol(" -123", nullptr, 0));
+ }
+}
+BIONIC_BENCHMARK(BM_stdlib_strtol);
+
+void BM_stdlib_strtoll(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ benchmark::DoNotOptimize(strtoll(" -123", nullptr, 0));
+ }
+}
+BIONIC_BENCHMARK(BM_stdlib_strtoll);
+
+void BM_stdlib_strtoul(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ benchmark::DoNotOptimize(strtoul(" -123", nullptr, 0));
+ }
+}
+BIONIC_BENCHMARK(BM_stdlib_strtoul);
+
+void BM_stdlib_strtoull(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ benchmark::DoNotOptimize(strtoull(" -123", nullptr, 0));
+ }
+}
+BIONIC_BENCHMARK(BM_stdlib_strtoull);