From 66f93291ec62682b48ef2411295843a04cbfd8e5 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Wed, 19 Feb 2014 19:08:12 -0800 Subject: [PATCH] Move time out of extra (cc #8784) --- AUTHORS.txt | 1 + mk/crates.mk | 9 +++++---- src/doc/rust.md | 6 +++--- src/libextra/lib.rs | 2 +- src/librustc/lib.rs | 1 + src/librustc/metadata/loader.rs | 3 ++- src/librustc/middle/trans/base.rs | 3 ++- src/librustc/util/common.rs | 3 ++- src/librustdoc/lib.rs | 2 +- src/libtest/lib.rs | 3 ++- src/{libextra/time.rs => libtime/lib.rs} | 10 +++++++++- src/llvm | 2 +- src/test/bench/core-map.rs | 3 +-- src/test/bench/core-set.rs | 10 +++++----- src/test/bench/core-std.rs | 4 ++-- src/test/bench/msgsend-pipes-shared.rs | 6 +++--- src/test/bench/msgsend-pipes.rs | 6 +++--- src/test/bench/msgsend-ring-mutex-arcs.rs | 3 +-- src/test/bench/msgsend-ring-rw-arcs.rs | 3 +-- src/test/bench/shootout-pfib.rs | 3 +-- src/test/bench/std-smallintmap.rs | 8 ++++---- src/test/bench/task-perf-alloc-unwind.rs | 4 ++-- src/test/run-pass/auto-encode.rs | 2 +- 23 files changed, 54 insertions(+), 43 deletions(-) rename src/{libextra/time.rs => libtime/lib.rs} (99%) diff --git a/AUTHORS.txt b/AUTHORS.txt index 2d0cc16d189..dd9dedc0d81 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -7,6 +7,7 @@ Adrien Tétar Alan Andrade Aleksander Balicki Alex Crichton +Alex Lyon Alex Rønne Petersen Alexander Stavonin Alexandros Tasos diff --git a/mk/crates.mk b/mk/crates.mk index f8bb9fbb408..af791c54edd 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -50,21 +50,21 @@ ################################################################################ TARGET_CRATES := std extra green rustuv native flate arena glob term semver \ - uuid serialize sync getopts collections num test + uuid serialize sync getopts collections num test time HOST_CRATES := syntax rustc rustdoc fourcc CRATES := $(TARGET_CRATES) $(HOST_CRATES) TOOLS := compiletest rustdoc rustc DEPS_std := native:rustrt native:compiler-rt -DEPS_extra := std term sync serialize getopts collections +DEPS_extra := std term sync serialize getopts collections time DEPS_green := std native:context_switch DEPS_rustuv := std native:uv native:uv_support DEPS_native := std DEPS_syntax := std term serialize collections DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \ - collections extra + collections time extra DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \ - test + test time DEPS_flate := std native:miniz DEPS_arena := std collections DEPS_glob := std @@ -78,6 +78,7 @@ DEPS_collections := std serialize DEPS_fourcc := syntax std DEPS_num := std extra DEPS_test := std extra collections getopts serialize term +DEPS_time := std serialize TOOL_DEPS_compiletest := test green rustuv getopts TOOL_DEPS_rustdoc := rustdoc green rustuv diff --git a/src/doc/rust.md b/src/doc/rust.md index 65a570f5f41..9fbf3a678f7 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -875,14 +875,14 @@ An example of what will and will not work for `use` items: ~~~~ # #[allow(unused_imports)]; -use foo::extra; // good: foo is at the root of the crate +use foo::extra::json; // good: foo is at the root of the crate use foo::baz::foobaz; // good: foo is at the root of the crate mod foo { extern crate extra; - use foo::extra::time; // good: foo is at crate root -// use extra::*; // bad: extra is not at the crate root + use foo::extra::json; // good: foo is at crate root +// use extra::json::*; // bad: extra is not at the crate root use self::baz::foobaz; // good: self refers to module 'foo' use foo::bar::foobar; // good: foo is at crate root diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs index d05fc00f06e..ac40b504f0c 100644 --- a/src/libextra/lib.rs +++ b/src/libextra/lib.rs @@ -37,13 +37,13 @@ Rust extras are part of the standard Rust distribution. extern crate sync; extern crate serialize; extern crate collections; +extern crate time; // Utility modules pub mod c_vec; pub mod url; pub mod json; pub mod tempfile; -pub mod time; pub mod workcache; pub mod stats; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 6554ee59229..0361b59eb2c 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -39,6 +39,7 @@ extern crate serialize; extern crate sync; extern crate getopts; extern crate collections; +extern crate time; use back::link; use driver::session; diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 903a93816dd..3f35b5cf2a1 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -32,7 +32,9 @@ use std::io; use std::os::consts::{macos, freebsd, linux, android, win32}; use std::str; use std::vec; + use flate; +use time; pub enum Os { OsMacos, @@ -361,7 +363,6 @@ impl ArchiveMetadata { // Just a small wrapper to time how long reading metadata takes. fn get_metadata_section(os: Os, filename: &Path) -> Option { - use extra::time; let start = time::precise_time_ns(); let ret = get_metadata_section_imp(os, filename); info!("reading {} => {}ms", filename.filename_display(), diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c14d98a487d..0b9ecf0dd8a 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -72,7 +72,6 @@ use util::ppaux::{Repr, ty_to_str}; use util::sha2::Sha256; use arena::TypedArena; -use extra::time; use std::c_str::ToCStr; use std::cell::{Cell, RefCell}; use std::hashmap::HashMap; @@ -90,6 +89,8 @@ use syntax::visit::Visitor; use syntax::visit; use syntax::{ast, ast_util, ast_map}; +use time; + pub use middle::trans::context::task_llcx; local_data_key!(task_local_insn_key: ~[&'static str]) diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 586ed080835..c139e21c864 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -16,7 +16,8 @@ use syntax::visit; use syntax::visit::Visitor; use std::local_data; -use extra::time; + +use time; pub fn time(do_it: bool, what: &str, u: U, f: |U| -> T) -> T { local_data_key!(depth: uint); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 6502ab1dce3..c6732b5d9e9 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -24,6 +24,7 @@ extern crate sync; extern crate getopts; extern crate collections; extern crate testing = "test"; +extern crate time; use std::local_data; use std::io; @@ -31,7 +32,6 @@ use std::io::{File, MemWriter}; use std::str; use extra::json; use serialize::{Decodable, Encodable}; -use extra::time; pub mod clean; pub mod core; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 4a9575c78f4..19c2f80cdbd 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -26,13 +26,14 @@ extern crate extra; extern crate getopts; extern crate serialize; extern crate term; +extern crate time; use collections::TreeMap; use extra::json::ToJson; use extra::json; use extra::stats::Stats; use extra::stats; -use extra::time::precise_time_ns; +use time::precise_time_ns; use getopts::{OptGroup, optflag, optopt}; use serialize::Decodable; use term::Terminal; diff --git a/src/libextra/time.rs b/src/libtime/lib.rs similarity index 99% rename from src/libextra/time.rs rename to src/libtime/lib.rs index 0a122ad58bd..1f0a0686658 100644 --- a/src/libextra/time.rs +++ b/src/libtime/lib.rs @@ -8,8 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[crate_id = "time#0.10-pre"]; +#[crate_type = "rlib"]; +#[crate_type = "dylib"]; +#[license = "MIT/ASL2"]; + #[allow(missing_doc)]; +extern crate serialize; + use std::io::BufReader; use std::libc; use std::num; @@ -1035,7 +1042,8 @@ pub fn strftime(format: &str, tm: &Tm) -> ~str { #[cfg(test)] mod tests { - use super::*; + use super::{Timespec, get_time, precise_time_ns, precise_time_s, tzset, + at_utc, at, strptime}; use std::f64; use std::result::{Err, Ok}; diff --git a/src/llvm b/src/llvm index b015ecddd31..f5f1ffea207 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit b015ecddd3129490fa26e5278a1acee79f2ee5ef +Subproject commit f5f1ffea207b6b380127ff34f14015ae005d1413 diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 61b3ccd1f54..ac77e62f2c0 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -8,10 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate extra; extern crate collections; +extern crate time; -use extra::time; use collections::TreeMap; use std::hashmap::{HashMap, HashSet}; use std::os; diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index 41c48d92692..25ced5f35da 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -10,8 +10,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate extra; extern crate collections; +extern crate time; use collections::bitv::BitvSet; use collections::TreeSet; @@ -31,9 +31,9 @@ struct Results { } fn timed(result: &mut f64, op: ||) { - let start = extra::time::precise_time_s(); + let start = time::precise_time_s(); op(); - let end = extra::time::precise_time_s(); + let end = time::precise_time_s(); *result = (end - start); } @@ -191,13 +191,13 @@ fn main() { let s: TreeSet<~str> = TreeSet::new(); s }); - write_results("extra::treemap::TreeSet", &results); + write_results("collections::TreeSet", &results); } { let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(seed); let mut results = empty_results(); results.bench_int(&mut rng, num_keys, max, || BitvSet::new()); - write_results("extra::bitv::BitvSet", &results); + write_results("collections::bitv::BitvSet", &results); } } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 9c29b691173..7b23e27e82a 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -12,9 +12,9 @@ #[feature(macro_rules)]; -extern crate extra; +extern crate time; -use extra::time::precise_time_s; +use time::precise_time_s; use std::mem::swap; use std::os; use std::rand::Rng; diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index ae1ae0a4367..68f5bba159f 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -18,7 +18,7 @@ // different scalability characteristics compared to the select // version. -extern crate extra; +extern crate time; use std::comm; use std::os; @@ -58,7 +58,7 @@ fn run(args: &[~str]) { let size = from_str::(args[1]).unwrap(); let workers = from_str::(args[2]).unwrap(); let num_bytes = 100; - let start = extra::time::precise_time_s(); + let start = time::precise_time_s(); let mut worker_results = ~[]; for _ in range(0u, workers) { let to_child = to_child.clone(); @@ -84,7 +84,7 @@ fn run(args: &[~str]) { to_child.send(stop); move_out(to_child); let result = from_child.recv(); - let end = extra::time::precise_time_s(); + let end = time::precise_time_s(); let elapsed = end - start; print!("Count is {:?}\n", result); print!("Test took {:?} seconds\n", elapsed); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index ca06e96f0c0..9da4a706562 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -14,7 +14,7 @@ // // I *think* it's the same, more or less. -extern crate extra; +extern crate time; use std::os; use std::task; @@ -52,7 +52,7 @@ fn run(args: &[~str]) { let size = from_str::(args[1]).unwrap(); let workers = from_str::(args[2]).unwrap(); let num_bytes = 100; - let start = extra::time::precise_time_s(); + let start = time::precise_time_s(); let mut worker_results = ~[]; let from_parent = if workers == 1 { let (from_parent, to_child) = Chan::new(); @@ -94,7 +94,7 @@ fn run(args: &[~str]) { //to_child.send(stop); //move_out(to_child); let result = from_child.recv(); - let end = extra::time::precise_time_s(); + let end = time::precise_time_s(); let elapsed = end - start; print!("Count is {:?}\n", result); print!("Test took {:?} seconds\n", elapsed); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 5dcccf8d861..6b91d1d534b 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -15,13 +15,12 @@ // This also serves as a pipes test, because Arcs are implemented with pipes. -extern crate extra; extern crate sync; +extern crate time; use sync::Arc; use sync::MutexArc; use sync::Future; -use extra::time; use std::os; use std::uint; diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index 3d619f2e313..2d52f125747 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -15,12 +15,11 @@ // This also serves as a pipes test, because Arcs are implemented with pipes. -extern crate extra; extern crate sync; +extern crate time; use sync::RWArc; use sync::Future; -use extra::time; use std::os; use std::uint; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 48aaa7d5b0a..11a843d6cb5 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -18,10 +18,9 @@ */ -extern crate extra; extern crate getopts; +extern crate time; -use extra::time; use std::os; use std::result::{Ok, Err}; use std::task; diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index 6f9c6abea1b..98deeec7e18 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -10,8 +10,8 @@ // Microbenchmark for the smallintmap library -extern crate extra; extern crate collections; +extern crate time; use collections::SmallIntMap; use std::os; @@ -46,11 +46,11 @@ fn main() { for _ in range(0u, rep) { let mut map = SmallIntMap::new(); - let start = extra::time::precise_time_s(); + let start = time::precise_time_s(); append_sequential(0u, max, &mut map); - let mid = extra::time::precise_time_s(); + let mid = time::precise_time_s(); check_sequential(0u, max, &map); - let end = extra::time::precise_time_s(); + let end = time::precise_time_s(); checkf += (end - mid) as f64; appendf += (mid - start) as f64; diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 51eb65b1d5c..d4f9d0572b0 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -10,11 +10,11 @@ #[feature(managed_boxes)]; -extern crate extra; extern crate collections; +extern crate time; use collections::list::{List, Cons, Nil}; -use extra::time::precise_time_s; +use time::precise_time_s; use std::os; use std::task; diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index caf9a92bba3..5383e9d5479 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -14,6 +14,7 @@ #[feature(managed_boxes)]; extern crate extra; +extern crate time; // These tests used to be separate files, but I wanted to refactor all // the common code. @@ -26,7 +27,6 @@ use std::cmp::Eq; use std::cmp; use std::io; use serialize::{Decodable, Encodable}; -use extra::time; fn test_ebml<'a, A: Eq +