about summary refs log tree commit diff
path: root/src/test/bench/std-smallintmap.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-11-10 12:27:56 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-11-12 09:18:35 -0800
commitfcd05ed99ff0aa6157e427a698ac53dbc450135f (patch)
tree62503d355c71c9daf045c0080912fe06ee2f5441 /src/test/bench/std-smallintmap.rs
parente4ead7b034c96b705ec34b8325f5f9f778f1cbb9 (diff)
downloadrust-fcd05ed99ff0aa6157e427a698ac53dbc450135f.tar.gz
rust-fcd05ed99ff0aa6157e427a698ac53dbc450135f.zip
time: Deprecate the library in the distribution
This commit deprecates the entire libtime library in favor of the
externally-provided libtime in the rust-lang organization. Users of the
`libtime` crate as-is today should add this to their Cargo manifests:

    [dependencies.time]
    git = "https://github.com/rust-lang/time"

To implement this transition, a new function `Duration::span` was added to the
`std::time::Duration` time. This function takes a closure and then returns the
duration of time it took that closure to execute. This interface will likely
improve with `FnOnce` unboxed closures as moving in and out will be a little
easier.

Due to the deprecation of the in-tree crate, this is a:

[breaking-change]

cc #18855, some of the conversions in the `src/test/bench` area may have been a
little nicer with that implemented
Diffstat (limited to 'src/test/bench/std-smallintmap.rs')
-rw-r--r--src/test/bench/std-smallintmap.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs
index cdcb88d87c6..576d96ba2a3 100644
--- a/src/test/bench/std-smallintmap.rs
+++ b/src/test/bench/std-smallintmap.rs
@@ -10,11 +10,9 @@
 
 // Microbenchmark for the smallintmap library
 
-extern crate collections;
-extern crate time;
-
 use std::collections::VecMap;
 use std::os;
+use std::time::Duration;
 use std::uint;
 
 fn append_sequential(min: uint, max: uint, map: &mut VecMap<uint>) {
@@ -41,25 +39,22 @@ fn main() {
     let max = from_str::<uint>(args[1].as_slice()).unwrap();
     let rep = from_str::<uint>(args[2].as_slice()).unwrap();
 
-    let mut checkf = 0.0;
-    let mut appendf = 0.0;
+    let mut checkf = Duration::seconds(0);
+    let mut appendf = Duration::seconds(0);
 
     for _ in range(0u, rep) {
         let mut map = VecMap::new();
-        let start = time::precise_time_s();
-        append_sequential(0u, max, &mut map);
-        let mid = time::precise_time_s();
-        check_sequential(0u, max, &map);
-        let end = time::precise_time_s();
+        let d1 = Duration::span(|| append_sequential(0u, max, &mut map));
+        let d2 = Duration::span(|| check_sequential(0u, max, &map));
 
-        checkf += (end - mid) as f64;
-        appendf += (mid - start) as f64;
+        checkf = checkf + d2;
+        appendf = appendf + d1;
     }
 
     let maxf = max as f64;
 
     println!("insert(): {} seconds\n", checkf);
-    println!("        : {} op/sec\n", maxf/checkf);
+    println!("        : {} op/ms\n", maxf / checkf.num_milliseconds() as f64);
     println!("get()   : {} seconds\n", appendf);
-    println!("        : {} op/sec\n", maxf/appendf);
+    println!("        : {} op/ms\n", maxf / appendf.num_milliseconds() as f64);
 }