MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / parse_perf_script

Function parse_perf_script

src/commands/hot_blocks.rs:514–524  ·  view source on GitHub ↗

Parse `perf script -F ip,sym,symoff,dso` output to extract samples that come from a perf map (i.e. compiled WebAssembly code and trampolines).

(output: &str)

Source from the content-addressed store, hash-verified

512/// Parse `perf script -F ip,sym,symoff,dso` output to extract samples that
513/// come from a perf map (i.e. compiled WebAssembly code and trampolines).
514fn parse_perf_script(output: &str) -> (Vec<PerfSample>, usize) {
515 let mut samples = Vec::new();
516 let mut total_samples = 0;
517 for line in output.lines() {
518 total_samples += 1;
519 if let Some(sample) = parse_perf_script_line(line.trim()) {
520 samples.push(sample);
521 }
522 }
523 (samples, total_samples)
524}
525
526fn parse_perf_script_line(line: &str) -> Option<PerfSample> {
527 // perf script -F ip,sym,symoff,dso gives lines like:

Callers 2

run_perf_scriptMethod · 0.85
test_parse_perf_scriptFunction · 0.85

Calls 3

parse_perf_script_lineFunction · 0.85
newFunction · 0.50
pushMethod · 0.45

Tested by 1

test_parse_perf_scriptFunction · 0.68