diff options
| author | Seo Sanghyeon <sanxiyn@gmail.com> | 2013-03-21 18:50:02 +0900 |
|---|---|---|
| committer | Seo Sanghyeon <sanxiyn@gmail.com> | 2013-03-21 18:50:02 +0900 |
| commit | 64d923f7ddf467e5dfa1999329362c42c892bf3d (patch) | |
| tree | 29c03872c4bf70dd88a764d229cbf31fb33737d5 | |
| parent | a14ec73cd2d15a2454113011835557ccf447f14d (diff) | |
| download | rust-64d923f7ddf467e5dfa1999329362c42c892bf3d.tar.gz rust-64d923f7ddf467e5dfa1999329362c42c892bf3d.zip | |
Move the function to time passes to util
| -rw-r--r-- | src/librustc/driver/driver.rs | 12 | ||||
| -rw-r--r-- | src/librustc/util/common.rs | 10 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index c4db61842a5..79faf3c516a 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -21,6 +21,7 @@ use metadata::{creader, cstore, filesearch}; use metadata; use middle::{trans, freevars, kind, ty, typeck, lint, astencode}; use middle; +use util::common::time; use util::ppaux; use core::int; @@ -32,7 +33,6 @@ use core::vec; use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; use std::getopts::{opt_present}; use std::getopts; -use std; use syntax::ast; use syntax::attr; use syntax::codemap; @@ -164,16 +164,6 @@ pub fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input) } } -pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { - if !do_it { return thunk(); } - let start = std::time::precise_time_s(); - let rv = thunk(); - let end = std::time::precise_time_s(); - io::stdout().write_str(fmt!("time: %3.3f s\t%s\n", - end - start, what)); - rv -} - #[deriving_eq] pub enum compile_upto { cu_parse, diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index c7945f74f55..1cd3982c7e8 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -16,6 +16,16 @@ use syntax::visit; use core::str; use std::oldmap::HashMap; +use std; + +pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { + if !do_it { return thunk(); } + let start = std::time::precise_time_s(); + let rv = thunk(); + let end = std::time::precise_time_s(); + io::println(fmt!("time: %3.3f s\t%s", end - start, what)); + rv +} pub fn indent<R>(op: &fn() -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` |
