diff options
| author | Dennis Kobert <dennis@kobert.dev> | 2025-03-10 21:36:30 +0100 |
|---|---|---|
| committer | Dennis Kobert <dennis@kobert.dev> | 2025-03-25 15:52:04 +0100 |
| commit | 776dee32aca73ded5c0720afbe25ef2aae7b67f3 (patch) | |
| tree | 1e4c8b9bde5c944869134e0ed751315efe09198a /perf-event/src | |
| parent | c2d63b96cbbd3be653fa0023fadae7df3babaf32 (diff) | |
Implement benchmarking
Diffstat (limited to 'perf-event/src')
| -rw-r--r-- | perf-event/src/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/perf-event/src/lib.rs b/perf-event/src/lib.rs index 03ef643..d1478fe 100644 --- a/perf-event/src/lib.rs +++ b/perf-event/src/lib.rs @@ -453,6 +453,8 @@ impl<'a> Default for Builder<'a> { attrs.set_disabled(1); attrs.set_exclude_kernel(1); // don't count time in kernel attrs.set_exclude_hv(1); // don't count time in hypervisor + attrs.set_exclude_kernel(0); // don't count time in kernel + attrs.set_exclude_hv(0); // don't count time in hypervisor // Request data for `time_enabled` and `time_running`. attrs.read_format |= sys::bindings::PERF_FORMAT_TOTAL_TIME_ENABLED as u64 @@ -760,6 +762,11 @@ impl Group { /// Construct a new, empty `Group`. #[allow(unused_parens)] pub fn new() -> io::Result<Group> { + Self::new_with_pid_and_cpu(0, -1) + } + + /// Construct a new, empty `Group` with cpu and pid set. + pub fn new_with_pid_and_cpu(pid: i32, cpu: i32) -> io::Result<Group> { // Open a placeholder perf counter that we can add other events to. let mut attrs = perf_event_attr { size: std::mem::size_of::<perf_event_attr>() as u32, @@ -780,7 +787,7 @@ impl Group { let file = unsafe { File::from_raw_fd(check_errno_syscall(|| { - sys::perf_event_open(&mut attrs, 0, -1, -1, 0) + sys::perf_event_open(&mut attrs, pid, cpu, -1, 0) })?) }; |
