Skip to content

Commit

Permalink
Replace Duration::as_secs_f64 implementation by the standard one
Browse files Browse the repository at this point in the history
Signed-off-by: MusiKid <musikid@outlook.com>
  • Loading branch information
musikid authored and svartalf committed Dec 30, 2020
1 parent c111eb4 commit 21630c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions heim-cpu/src/usage.rs
Expand Up @@ -25,11 +25,7 @@ impl ops::Sub<CpuUsage> for CpuUsage {
+ (self.cpu_time.system() - rhs.cpu_time.system());
let delta_time = self.at - rhs.at;

// TODO: Can be replaced with a `delta_time.as_secs_f64()`
// as soon as https://github.com/rust-lang/rust/issues/54361 will be stable
const NANOS_PER_SEC: u32 = 1_000_000_000;
let mut delta_time_secs =
(delta_time.as_secs() as f64) + (delta_time.as_nanos() as f64) / (NANOS_PER_SEC as f64);
let mut delta_time_secs = delta_time.as_secs_f64();

// Time should calculated across all the cores available
delta_time_secs *= self.cpu_count as f64;
Expand Down
6 changes: 1 addition & 5 deletions heim-process/src/process/cpu_usage.rs
Expand Up @@ -24,11 +24,7 @@ impl ops::Sub<CpuUsage> for CpuUsage {
+ (self.cpu_time.system() - rhs.cpu_time.system());
let delta_time = self.at - rhs.at;

// TODO: Can be replaced with a `delta_time.as_secs_f64()`
// as soon as https://github.com/rust-lang/rust/issues/54361 will be stable
const NANOS_PER_SEC: u32 = 1_000_000_000;
let mut delta_time_secs =
(delta_time.as_secs() as f64) + (delta_time.as_nanos() as f64) / (NANOS_PER_SEC as f64);
let mut delta_time_secs = delta_time.as_secs_f64();

// Time should calculated across all the cores available
delta_time_secs *= self.cpu_count as f64;
Expand Down

0 comments on commit 21630c4

Please sign in to comment.