Navigation Menu

Skip to content

Commit

Permalink
Move time out of extra (cc #8784)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcterus committed Feb 21, 2014
1 parent 2fa7d6b commit 66f9329
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 43 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Expand Up @@ -7,6 +7,7 @@ Adrien Tétar <adri-from-59@hotmail.fr>
Alan Andrade <alan.andradec@gmail.com>
Aleksander Balicki <balicki.aleksander@gmail.com>
Alex Crichton <alex@alexcrichton.com>
Alex Lyon <arcterus@mail.com>
Alex Rønne Petersen <alex@lycus.org>
Alexander Stavonin <a.stavonin@gmail.com>
Alexandros Tasos <sdi1100085@di.uoa.gr>
Expand Down
9 changes: 5 additions & 4 deletions mk/crates.mk
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/doc/rust.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/lib.rs
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/loader.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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<MetadataBlob> {
use extra::time;
let start = time::precise_time_ns();
let ret = get_metadata_section_imp(os, filename);
info!("reading {} => {}ms", filename.filename_display(),
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/base.rs
Expand Up @@ -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;
Expand All @@ -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])
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/util/common.rs
Expand Up @@ -16,7 +16,8 @@ use syntax::visit;
use syntax::visit::Visitor;

use std::local_data;
use extra::time;

use time;

pub fn time<T, U>(do_it: bool, what: &str, u: U, f: |U| -> T) -> T {
local_data_key!(depth: uint);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Expand Up @@ -24,14 +24,14 @@ extern crate sync;
extern crate getopts;
extern crate collections;
extern crate testing = "test";
extern crate time;

use std::local_data;
use std::io;
use std::io::{File, MemWriter};
use std::str;
use extra::json;
use serialize::{Decodable, Encodable};
use extra::time;

pub mod clean;
pub mod core;
Expand Down
3 changes: 2 additions & 1 deletion src/libtest/lib.rs
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion src/libextra/time.rs → src/libtime/lib.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down
3 changes: 1 addition & 2 deletions src/test/bench/core-map.rs
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/test/bench/core-set.rs
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/test/bench/core-std.rs
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/test/bench/msgsend-pipes-shared.rs
Expand Up @@ -18,7 +18,7 @@
// different scalability characteristics compared to the select
// version.

extern crate extra;
extern crate time;

use std::comm;
use std::os;
Expand Down Expand Up @@ -58,7 +58,7 @@ fn run(args: &[~str]) {
let size = from_str::<uint>(args[1]).unwrap();
let workers = from_str::<uint>(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();
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/test/bench/msgsend-pipes.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -52,7 +52,7 @@ fn run(args: &[~str]) {
let size = from_str::<uint>(args[1]).unwrap();
let workers = from_str::<uint>(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();
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/test/bench/msgsend-ring-mutex-arcs.rs
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/test/bench/msgsend-ring-rw-arcs.rs
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/test/bench/shootout-pfib.rs
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/test/bench/std-smallintmap.rs
Expand Up @@ -10,8 +10,8 @@

// Microbenchmark for the smallintmap library

extern crate extra;
extern crate collections;
extern crate time;

use collections::SmallIntMap;
use std::os;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/bench/task-perf-alloc-unwind.rs
Expand Up @@ -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;

Expand Down

5 comments on commit 66f9329

@bors
Copy link
Contributor

@bors bors commented on 66f9329 Feb 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at Arcterus@66f9329

@bors
Copy link
Contributor

@bors bors commented on 66f9329 Feb 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Arcterus/rust/time = 66f9329 into auto

@bors
Copy link
Contributor

@bors bors commented on 66f9329 Feb 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arcterus/rust/time = 66f9329 merged ok, testing candidate = 56cf237

@bors
Copy link
Contributor

@bors bors commented on 66f9329 Feb 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 66f9329 Feb 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 56cf237

Please sign in to comment.