summaryrefslogtreecommitdiff
path: root/libunwindstack/benchmarks/OfflineUnwindBenchmarks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/benchmarks/OfflineUnwindBenchmarks.cpp')
-rw-r--r--libunwindstack/benchmarks/OfflineUnwindBenchmarks.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/libunwindstack/benchmarks/OfflineUnwindBenchmarks.cpp b/libunwindstack/benchmarks/OfflineUnwindBenchmarks.cpp
index b06c5ee..52525d8 100644
--- a/libunwindstack/benchmarks/OfflineUnwindBenchmarks.cpp
+++ b/libunwindstack/benchmarks/OfflineUnwindBenchmarks.cpp
@@ -42,47 +42,45 @@ class OfflineUnwindBenchmark : public benchmark::Fixture {
}
void RunBenchmark(benchmark::State& state, const std::string& offline_files_dir,
- size_t expected_num_frames, ArchEnum arch, bool cache_maps, bool is_jit_debug) {
+ size_t expected_num_frames, ArchEnum arch, ProcessMemoryFlag memory_flag,
+ bool cache_maps = false) {
std::string error_msg;
- if (!offline_utils_.Init(offline_files_dir, arch, error_msg, /*add_stack=*/true, cache_maps)) {
- state.SkipWithError(error_msg.c_str());
- return;
- }
- if (is_jit_debug && !offline_utils_.SetJitProcessMemory(error_msg)) {
+ if (!offline_utils_.Init(offline_files_dir, arch, &error_msg, memory_flag, cache_maps)) {
state.SkipWithError(error_msg.c_str());
return;
}
- std::unique_ptr<JitDebug> jit_debug;
- std::stringstream err_stream;
- Unwinder unwinder(0, nullptr, nullptr);
for (auto _ : state) {
state.PauseTiming();
// Need to init unwinder with new copy of regs each iteration because unwinding changes
// the attributes of the regs object.
std::unique_ptr<Regs> regs_copy(offline_utils_.GetRegs()->Clone());
- // If we don't want to use cached maps, make sure to reset them.
- if (!cache_maps && !offline_utils_.ResetMaps(error_msg)) {
- state.SkipWithError(error_msg.c_str());
- return;
+ // The Maps object will still hold the parsed maps from the previous unwinds. So reset them
+ // unless we want to assume all Maps are cached.
+ if (!cache_maps) {
+ if (!offline_utils_.CreateMaps(&error_msg)) {
+ state.SkipWithError(error_msg.c_str());
+ return;
+ }
}
mem_tracker_.StartTrackingAllocations();
state.ResumeTiming();
- std::shared_ptr<Memory> process_memory = offline_utils_.GetProcessMemory();
- unwinder = Unwinder(128, offline_utils_.GetMaps(), regs_copy.get(), process_memory);
- if (is_jit_debug) {
- jit_debug = CreateJitDebug(regs_copy->Arch(), process_memory);
- unwinder.SetJitDebug(jit_debug.get());
+ Unwinder unwinder = Unwinder(128, offline_utils_.GetMaps(), regs_copy.get(),
+ offline_utils_.GetProcessMemory());
+ if (memory_flag == ProcessMemoryFlag::kIncludeJitMemory) {
+ unwinder.SetJitDebug(offline_utils_.GetJitDebug());
}
unwinder.Unwind();
state.PauseTiming();
mem_tracker_.StopTrackingAllocations();
if (unwinder.NumFrames() != expected_num_frames) {
+ std::stringstream err_stream;
err_stream << "Failed to unwind properly.Expected " << expected_num_frames
<< " frames, but unwinder contained " << unwinder.NumFrames() << " frames.\n";
- break;
+ state.SkipWithError(err_stream.str().c_str());
+ return;
}
state.ResumeTiming();
}
@@ -95,18 +93,18 @@ class OfflineUnwindBenchmark : public benchmark::Fixture {
BENCHMARK_F(OfflineUnwindBenchmark, BM_offline_straddle_arm64)(benchmark::State& state) {
RunBenchmark(state, "straddle_arm64/", /*expected_num_frames=*/6, ARCH_ARM64,
- /*cached_maps=*/false, /*is_jit_debug=*/false);
+ ProcessMemoryFlag::kNone);
}
BENCHMARK_F(OfflineUnwindBenchmark, BM_offline_straddle_arm64_cached_maps)
(benchmark::State& state) {
RunBenchmark(state, "straddle_arm64/", /*expected_num_frames=*/6, ARCH_ARM64,
- /*cached_maps=*/true, /*is_jit_debug=*/false);
+ ProcessMemoryFlag::kNone, /*cached_maps=*/true);
}
-BENCHMARK_F(OfflineUnwindBenchmark, BM_offline_jit_debug_x86)(benchmark::State& state) {
- RunBenchmark(state, "jit_debug_x86/", /*expected_num_frames=*/69, ARCH_X86,
- /*cached_maps=*/false, /*is_jit_debug=*/true);
+BENCHMARK_F(OfflineUnwindBenchmark, BM_offline_jit_debug_arm)(benchmark::State& state) {
+ RunBenchmark(state, "jit_debug_arm/", /*expected_num_frames=*/76, ARCH_ARM,
+ ProcessMemoryFlag::kIncludeJitMemory);
}
} // namespace