Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion perf-event/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "perf-event2"
version = "0.7.4"
version = "0.8.0"
description = "A Rust interface to Linux performance monitoring"
license = "MIT OR Apache-2.0"
authors = ["Sean Lynch <sean@lynches.ca>", "Jim Blandy <jimb@red-bean.com>"]
Expand Down Expand Up @@ -29,6 +29,7 @@ libc = "0.2"
memmap2 = "0.9"
perf-event-data = "0.1.8"
perf-event-open-sys2 = "5.0.4"
thiserror = "2.0.14"

[dev-dependencies]
ctrlc = "3.4.5"
Expand Down
21 changes: 21 additions & 0 deletions perf-event/examples/tracepoint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use perf_event::data::Record;
use perf_event::events::Tracepoint;
use perf_event::{Builder, CpuPid};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut counter = Builder::new(Tracepoint::with_name("net/net_dev_xmit")?)
.targeting(CpuPid::AnyProcessOneCpu { cpu: 0 })
.build()?
.sampled(8192)?;

counter.enable()?;

while let Some(record) = counter.next_blocking(None) {
println!("received event");
if let Ok(Record::Sample(sample)) = record.parse_record() {
dbg!(sample);
}
}

Ok(())
}
Loading
Loading