pub struct PerfFileReader<R: Read> {
pub perf_file: PerfFile,
pub record_iter: PerfRecordIter<R>,
}Expand description
A parser for the perf.data file format.
§Example
use linux_perf_data::{AttributeDescription, PerfFileReader, PerfFileRecord};
let file = std::fs::File::open("perf.data")?;
let reader = std::io::BufReader::new(file);
let PerfFileReader { mut perf_file, mut record_iter } = PerfFileReader::parse_file(reader)?;
let event_names: Vec<_> =
perf_file.event_attributes().iter().filter_map(AttributeDescription::name).collect();
println!("perf events: {}", event_names.join(", "));
while let Some(record) = record_iter.next_record(&mut perf_file)? {
match record {
PerfFileRecord::EventRecord { attr_index, record } => {
let record_type = record.record_type;
let parsed_record = record.parse()?;
println!("{:?} for event {}: {:?}", record_type, attr_index, parsed_record);
}
PerfFileRecord::UserRecord(record) => {
let record_type = record.record_type;
let parsed_record = record.parse()?;
println!("{:?}: {:?}", record_type, parsed_record);
}
}
}Fields§
§perf_file: PerfFile§record_iter: PerfRecordIter<R>Implementations§
Source§impl<C: Read + Seek> PerfFileReader<C>
impl<C: Read + Seek> PerfFileReader<C>
pub fn parse_file(cursor: C) -> Result<Self, Error>
Source§impl<R: Read> PerfFileReader<R>
impl<R: Read> PerfFileReader<R>
Sourcepub fn parse_pipe(reader: R) -> Result<Self, Error>
pub fn parse_pipe(reader: R) -> Result<Self, Error>
Parse a perf.data file in pipe mode (streaming format).
Pipe mode is designed for streaming and does not require seeking. Metadata (attributes and features) is embedded in the stream as synthesized records (PERF_RECORD_HEADER_ATTR, PERF_RECORD_HEADER_FEATURE).
Auto Trait Implementations§
impl<R> Freeze for PerfFileReader<R>where
PerfRecordIter<R>: Freeze,
impl<R> RefUnwindSafe for PerfFileReader<R>where
PerfRecordIter<R>: RefUnwindSafe,
impl<R> Send for PerfFileReader<R>where
PerfRecordIter<R>: Send,
impl<R> Sync for PerfFileReader<R>where
PerfRecordIter<R>: Sync,
impl<R> Unpin for PerfFileReader<R>where
PerfRecordIter<R>: Unpin,
impl<R> UnsafeUnpin for PerfFileReader<R>where
PerfRecordIter<R>: UnsafeUnpin,
impl<R> UnwindSafe for PerfFileReader<R>where
PerfRecordIter<R>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more