linux-perf-data
A parser for the perf.data file format.
Files of this format consist of a header, a data section, and a few other supplemental sections. The data section contains the main content of the file: a sequence of records.
There are two types of records: event records from the kernel, and "user records" from perf / simpleperf.
This crate also contains parsing code for jitdump files, which are used in conjunction with perf.data files when profiling JIT runtimes.
File Modes
This crate supports two modes for reading perf.data files:
- File mode (
parse_file) - For reading regular perf.data files from disk. RequiresRead + Seek. - Pipe mode (
parse_pipe) - For streaming perf.data from pipes, stdin, or network streams. Only requiresRead.
Examples
File Mode Example
use ;
let file = open?;
let reader = new;
let PerfFileReader = parse_file?;
let event_names: =
perf_file.event_attributes.iter.filter_map.collect;
println!;
while let Some = record_iter.next_record?
Pipe Mode Example
Read perf.data from stdin or a pipe (no seeking required):
use ;
// Read from stdin
let stdin = stdin;
let PerfFileReader = parse_pipe?;
println!;
while let Some = record_iter.next_record?
Command-line usage:
# Stream directly from perf record
|
# Or pipe an existing file
|
Jitdump example
use ;
let file = open?;
let mut reader = new?;
println!;
while let Some = reader.next_record?
License
Licensed under either of
- Apache License, Version 2.0 (
LICENSE-APACHEor http://www.apache.org/licenses/LICENSE-2.0) - MIT license (
LICENSE-MITor http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.