rust/src/test/bench/task-perf-spawnalot.rs

23 lines
433 B
Rust
Raw Normal View History

2011-10-20 20:34:04 -07:00
fn f(&&n: uint) {
let mut i = 0u;
while i < n {
2012-06-30 16:19:07 -07:00
task::try(|| g() );
2011-09-02 15:34:58 -07:00
i += 1u;
}
}
2012-01-06 22:02:05 -08:00
fn g() { }
fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"400"]
} else if args.len() <= 1u {
~[~"", ~"10"]
} else {
args
};
let n = uint::from_str(args[1]).get();
let mut i = 0u;
2012-06-30 16:19:07 -07:00
while i < n { task::spawn(|| f(n) ); i += 1u; }
}