summaryrefslogtreecommitdiff
path: root/src/time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/time.rs')
-rw-r--r--src/time.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/time.rs b/src/time.rs
index 5bd0da8d..c13a640c 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -1,6 +1,5 @@
use std::io::{self, Write};
-use std::time::{Instant, Duration};
-
+use std::time::{Duration, Instant};
/// RAII timer to measure how long phases take.
#[derive(Debug)]
@@ -10,7 +9,6 @@ pub struct Timer<'a> {
start: Instant,
}
-
impl<'a> Timer<'a> {
/// Creates a Timer with the given name, and starts it. By default,
/// will print to stderr when it is `drop`'d
@@ -18,7 +16,7 @@ impl<'a> Timer<'a> {
Timer {
output: true,
name,
- start: Instant::now()
+ start: Instant::now(),
}
}
@@ -37,19 +35,16 @@ impl<'a> Timer<'a> {
fn print_elapsed(&mut self) {
if self.output {
let elapsed = self.elapsed();
- let time = (elapsed.as_secs() as f64) * 1e3
- + (elapsed.subsec_nanos() as f64) / 1e6;
+ let time = (elapsed.as_secs() as f64) * 1e3 +
+ (elapsed.subsec_nanos() as f64) / 1e6;
let stderr = io::stderr();
// Arbitrary output format, subject to change.
- writeln!(stderr.lock(),
- " time: {:>9.3} ms.\t{}",
- time, self.name)
- .expect("timer write should not fail");
+ writeln!(stderr.lock(), " time: {:>9.3} ms.\t{}", time, self.name)
+ .expect("timer write should not fail");
}
}
}
-
impl<'a> Drop for Timer<'a> {
fn drop(&mut self) {
self.print_elapsed();