Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit 9d3ab49

Browse files
committed
Update to time 0.3
1 parent b4fcc9f commit 9d3ab49

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
1414
serde-bench = { version = "0.0.7", optional = true }
1515
serde_json = { version = "1.0", optional = true }
1616
simd-json = { version = "0.4", optional = true}
17-
time = "0.1"
17+
time = "0.3"
1818

1919
[features]
2020
default = ["performance", "all-libs", "all-files"]

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn num_trials() -> Option<usize> {
3232
}
3333

3434
pub fn throughput(dur: time::Duration, bytes: usize) -> u64 {
35-
let mut megabytes_per_second = bytes as u64 / dur.num_microseconds().unwrap() as u64;
35+
let mut megabytes_per_second = bytes as u64 / dur.whole_microseconds() as u64;
3636

3737
// Round to two significant digits.
3838
if megabytes_per_second > 100 {

src/timer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::cmp;
22

3-
use time::{Duration, PreciseTime};
3+
use time::{Duration, Instant};
44

55
pub fn bench<T, F>(trials: usize, f: F) -> Duration
66
where
@@ -41,7 +41,7 @@ impl Benchmark {
4141
pub fn start<'a>(&'a mut self) -> Timer<'a> {
4242
Timer {
4343
source: self,
44-
start: PreciseTime::now(),
44+
start: Instant::now(),
4545
stopped: false,
4646
}
4747
}
@@ -53,13 +53,13 @@ impl Benchmark {
5353

5454
pub struct Timer<'a> {
5555
source: &'a mut Benchmark,
56-
start: PreciseTime,
56+
start: Instant,
5757
stopped: bool,
5858
}
5959

6060
impl<'a> Timer<'a> {
6161
pub fn stop(&mut self) {
62-
let elapsed = self.start.to(PreciseTime::now());
62+
let elapsed = self.start.elapsed();
6363
if self.stopped {
6464
panic!("already stopped");
6565
}

0 commit comments

Comments
 (0)