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
This commit is contained in:
Josh Gao 2017-10-26 13:57:40 -07:00
parent cd546c11d6
commit 3b094c169f
1 changed files with 7 additions and 10 deletions

View File

@ -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();