We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be99e50 commit 0c6338dCopy full SHA for 0c6338d
rayon-demo/src/cpu_time/mod.rs
@@ -16,7 +16,7 @@ pub fn get_cpu_time() -> Option<u64> {
16
}
17
18
pub fn get_cpu_duration(start: Option<u64>, stop: Option<u64>) -> Option<Duration> {
19
- start.and_then(|start| stop.and_then(|stop| Some(Duration::nanoseconds((stop - start) as i64))))
+ Some(Duration::nanoseconds((stop? - start?) as i64))
20
21
22
#[derive(Copy, Clone)]
@@ -41,7 +41,7 @@ pub fn measure_cpu(op: impl FnOnce()) -> CpuMeasure {
41
time_duration,
42
cpu_usage_percent: get_cpu_duration(cpu_start, cpu_stop)
43
.and_then(|cpu| cpu.num_nanoseconds())
44
- .and_then(|cpu| Some(100.0 * cpu as f64 / time_duration as f64)),
+ .map(|cpu| 100.0 * cpu as f64 / time_duration as f64),
45
46
47
0 commit comments