Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b094c16 authored by Josh Gao's avatar Josh Gao
Browse files

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
parent cd546c11
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -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,7 +131,6 @@ 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");
@@ -140,7 +138,6 @@ static void CreateMap(benchmark::State& state, BacktraceMap* (*map_func)(pid_t,
    }
    delete map;
  }
  }

  kill(pid, SIGKILL);
  waitpid(pid, nullptr, 0);
@@ -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();