rust/bench-cargo-miri/backtraces/src/main.rs
Ben Kimock 8a40e2e9e3 Add more bench-cargo-miri programs
These example programs are derived from long-running (>15 minutes) tests
in the test suites of highly-downloaded crates. They should serve as
realistic but also somewhat pathological workloads for the interpreter.

The unicode program stresses the code which looks for adjacent and equal
stacks to merge them.

The backtrace program has an uncommonly large working set of borrow tags
per borrow stack.

This also updates the .gitignore to ignore files commonly emitted in the
course of using these benchmark programs.
2022-06-08 21:35:02 -04:00

30 lines
1018 B
Rust

//! Extracted from the backtrace crate's test test_frame_conversion
use backtrace::{Backtrace, BacktraceFrame};
use std::fmt::Write;
fn main() {
let mut frames = vec![];
backtrace::trace(|frame| {
let converted = BacktraceFrame::from(frame.clone());
frames.push(converted);
true
});
let mut manual = Backtrace::from(frames);
manual.resolve();
let frames = manual.frames();
let mut output = String::new();
for frame in frames {
// Originally these were println! but we'd prefer our benchmarks to not emit a lot of
// output to stdout/stderr. Unfortunately writeln! to a String is faster, but we still
// manage to exercise interesting code paths in Miri.
writeln!(output, "{:?}", frame.ip()).unwrap();
writeln!(output, "{:?}", frame.symbol_address()).unwrap();
writeln!(output, "{:?}", frame.module_base_address()).unwrap();
writeln!(output, "{:?}", frame.symbols()).unwrap();
}
drop(output);
}