summaryrefslogtreecommitdiff
path: root/libbacktrace
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-10-26 13:57:40 -0700
committerJosh Gao <jmgao@google.com>2017-10-26 14:19:49 -0700
commit340fc8adcf9038b01d21587efda6837718eff154 (patch)
tree9092e8f69efca55915fc6e6fa72fd9b4c7be68c5 /libbacktrace
parent4cfb559e04f81b8873b369275ac7e780b4004637 (diff)
downloadunwinding-340fc8adcf9038b01d21587efda6837718eff154.tar.gz
libbacktrace: let the benchmark library decide iteration count.
Manually doing 1000 iterations of the benchmark doesn't seem to add any significant amount of precision, and it makes the benchmark take forever and obfuscates the results. Just let benchmark figure out the time (with the option of using command line flags to increase the number of iterations). Test: backtrace_benchmarks64 Change-Id: I8de912c1b3c904755c8e2ac4175ff70176544ba3
Diffstat (limited to 'libbacktrace')
-rw-r--r--libbacktrace/backtrace_benchmarks.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/libbacktrace/backtrace_benchmarks.cpp b/libbacktrace/backtrace_benchmarks.cpp
index aa1662f..9fdf60c 100644
--- a/libbacktrace/backtrace_benchmarks.cpp
+++ b/libbacktrace/backtrace_benchmarks.cpp
@@ -38,7 +38,6 @@
#define ANDROID_PR_SET_VMA_ANON_NAME 0
constexpr size_t kNumMaps = 2000;
-constexpr size_t kNumIterations = 1000;
static bool CountMaps(pid_t pid, size_t* num_maps) {
// Minimize the calls that might allocate memory. If too much memory
@@ -132,14 +131,12 @@ static void CreateMap(benchmark::State& state, BacktraceMap* (*map_func)(pid_t,
}
while (state.KeepRunning()) {
- for (size_t i = 0; i < static_cast<size_t>(state.range(0)); i++) {
- BacktraceMap* map = map_func(pid, false);
- if (map == nullptr) {
- fprintf(stderr, "Failed to create map\n");
- return;
- }
- delete map;
+ BacktraceMap* map = map_func(pid, false);
+ if (map == nullptr) {
+ fprintf(stderr, "Failed to create map\n");
+ return;
}
+ delete map;
}
kill(pid, SIGKILL);
@@ -149,11 +146,11 @@ static void CreateMap(benchmark::State& state, BacktraceMap* (*map_func)(pid_t,
static void BM_create_map(benchmark::State& state) {
CreateMap(state, BacktraceMap::Create);
}
-BENCHMARK(BM_create_map)->Arg(kNumIterations);
+BENCHMARK(BM_create_map);
static void BM_create_map_new(benchmark::State& state) {
CreateMap(state, BacktraceMap::CreateNew);
}
-BENCHMARK(BM_create_map_new)->Arg(kNumIterations);
+BENCHMARK(BM_create_map_new);
BENCHMARK_MAIN();