Skip to content

Commit

Permalink
Add total CPU time getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Savy committed Aug 3, 2022
1 parent af99d5c commit 2317e7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cpulimiter/src/limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,9 @@ impl CpuLimit {
pub fn cpu_usage(&self) -> f64 {
self.group.read().cpu_usage()
}

/// Retrieves the total amount of CPU time used by the target process.
pub fn total_cpu_time(&self) -> Duration {
self.group.read().total_cpu_time()
}
}
5 changes: 5 additions & 0 deletions cpulimiter/src/process_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ impl ProcessGroup {
self.cpu_usage
}

/// Retrieves the total amount of CPU time used.
pub fn total_cpu_time(&self) -> Duration {
self.total_time
}

/// Sends a signal to the target process and its children if needed.
fn kill(&self, signal: &Signal) {
let _ = self.target.kill(signal);
Expand Down

0 comments on commit 2317e7e

Please sign in to comment.