Move the function to time passes to util
This commit is contained in:
parent
a14ec73cd2
commit
64d923f7dd
2 changed files with 11 additions and 11 deletions
|
@ -21,6 +21,7 @@ use metadata::{creader, cstore, filesearch};
|
||||||
use metadata;
|
use metadata;
|
||||||
use middle::{trans, freevars, kind, ty, typeck, lint, astencode};
|
use middle::{trans, freevars, kind, ty, typeck, lint, astencode};
|
||||||
use middle;
|
use middle;
|
||||||
|
use util::common::time;
|
||||||
use util::ppaux;
|
use util::ppaux;
|
||||||
|
|
||||||
use core::int;
|
use core::int;
|
||||||
|
@ -32,7 +33,6 @@ use core::vec;
|
||||||
use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
|
use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
|
||||||
use std::getopts::{opt_present};
|
use std::getopts::{opt_present};
|
||||||
use std::getopts;
|
use std::getopts;
|
||||||
use std;
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap;
|
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]
|
#[deriving_eq]
|
||||||
pub enum compile_upto {
|
pub enum compile_upto {
|
||||||
cu_parse,
|
cu_parse,
|
||||||
|
|
|
@ -16,6 +16,16 @@ use syntax::visit;
|
||||||
|
|
||||||
use core::str;
|
use core::str;
|
||||||
use std::oldmap::HashMap;
|
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 {
|
pub fn indent<R>(op: &fn() -> R) -> R {
|
||||||
// Use in conjunction with the log post-processor like `src/etc/indenter`
|
// Use in conjunction with the log post-processor like `src/etc/indenter`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue