Skip to content

Commit 64d923f

Browse files
committed
Move the function to time passes to util
1 parent a14ec73 commit 64d923f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/librustc/driver/driver.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use metadata::{creader, cstore, filesearch};
2121
use metadata;
2222
use middle::{trans, freevars, kind, ty, typeck, lint, astencode};
2323
use middle;
24+
use util::common::time;
2425
use util::ppaux;
2526

2627
use core::int;
@@ -32,7 +33,6 @@ use core::vec;
3233
use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
3334
use std::getopts::{opt_present};
3435
use std::getopts;
35-
use std;
3636
use syntax::ast;
3737
use syntax::attr;
3838
use syntax::codemap;
@@ -164,16 +164,6 @@ pub fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input)
164164
}
165165
}
166166

167-
pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
168-
if !do_it { return thunk(); }
169-
let start = std::time::precise_time_s();
170-
let rv = thunk();
171-
let end = std::time::precise_time_s();
172-
io::stdout().write_str(fmt!("time: %3.3f s\t%s\n",
173-
end - start, what));
174-
rv
175-
}
176-
177167
#[deriving_eq]
178168
pub enum compile_upto {
179169
cu_parse,

src/librustc/util/common.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ use syntax::visit;
1616

1717
use core::str;
1818
use std::oldmap::HashMap;
19+
use std;
20+
21+
pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
22+
if !do_it { return thunk(); }
23+
let start = std::time::precise_time_s();
24+
let rv = thunk();
25+
let end = std::time::precise_time_s();
26+
io::println(fmt!("time: %3.3f s\t%s", end - start, what));
27+
rv
28+
}
1929

2030
pub fn indent<R>(op: &fn() -> R) -> R {
2131
// Use in conjunction with the log post-processor like `src/etc/indenter`

0 commit comments

Comments
 (0)