Skip to content

Commit

Permalink
Merge pull request OptimatistOpenSource#20 from Thaumy/rename-reset-c…
Browse files Browse the repository at this point in the history
…ount

Rename `reset_count` to `reset` for counting mode
  • Loading branch information
Thaumy authored Feb 20, 2024
2 parents aac8ea5 + a4e64b4 commit 9326bff
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/perf_event/counting/group/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ impl FixedCounterGroup {
self.inner().disable()
}

pub fn reset_count(&self) -> io::Result<()> {
self.inner().reset_count()
pub fn reset(&self) -> io::Result<()> {
self.inner().reset()
}

pub fn stat(&mut self) -> io::Result<CounterGroupStat> {
Expand Down
2 changes: 1 addition & 1 deletion src/perf_event/counting/group/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Inner {
)
}

pub fn reset_count(&self) -> io::Result<()> {
pub fn reset(&self) -> io::Result<()> {
self.leader().map_or_else(
|| Err(io::Error::new(ErrorKind::Other, "Group has no members")),
|leader| {
Expand Down
6 changes: 3 additions & 3 deletions src/perf_event/counting/group/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ where
{
test_stat(ev_1, ev_2, workload);
test_enable_disable(ev_1, ev_2, workload);
test_reset_count(ev_1, ev_2, workload);
test_reset(ev_1, ev_2, workload);
test_guard(ev_1, ev_2, workload);
}

Expand Down Expand Up @@ -99,7 +99,7 @@ where
assert!(evs.member_count(&ev_2_guard).unwrap() > ev_2);
}

fn test_reset_count<F>(ev_1: &Event, ev_2: &Event, workload: &mut F)
fn test_reset<F>(ev_1: &Event, ev_2: &Event, workload: &mut F)
where
F: FnMut(),
{
Expand All @@ -119,7 +119,7 @@ where
assert!(ev_2 > 0);
}

group.reset_count().unwrap();
group.reset().unwrap();

{
let evs = group.stat().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/perf_event/counting/single/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Counter {
ioctl_wrapped::<()>(&self.file, PERF_EVENT_IOCTL_DISABLE, None)
}

pub fn reset_count(&self) -> io::Result<()> {
pub fn reset(&self) -> io::Result<()> {
ioctl_wrapped::<()>(&self.file, PERF_EVENT_IOCTL_RESET, None)
}

Expand Down
6 changes: 3 additions & 3 deletions src/perf_event/counting/single/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ where
{
test_stat(ev, workload);
test_enable_disable(ev, workload);
test_reset_count(ev, workload);
test_reset(ev, workload);
}

fn gen_counter(ev: &Event) -> Counter {
Expand Down Expand Up @@ -58,7 +58,7 @@ where
assert!(after < counter.stat().unwrap().event_count);
}

fn test_reset_count<F>(ev: &Event, workload: &mut F)
fn test_reset<F>(ev: &Event, workload: &mut F)
where
F: FnMut(),
{
Expand All @@ -71,7 +71,7 @@ where
assert!(count > 0);

counter.disable().unwrap();
counter.reset_count().unwrap();
counter.reset().unwrap();
workload();
assert_eq!(counter.stat().unwrap().event_count, 0);
}

0 comments on commit 9326bff

Please sign in to comment.