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

19 lines
350 B
Rust
Raw Normal View History

2011-10-20 20:34:04 -07:00
fn f(&&n: uint) {
let i = 0u;
while i < n {
2012-02-18 16:34:42 -08:00
task::try {|| g() };
2011-09-02 15:34:58 -07:00
i += 1u;
}
}
2012-01-06 22:02:05 -08:00
fn g() { }
2011-09-02 15:34:58 -07:00
fn main(args: [str]) {
let n =
if vec::len(args) < 2u {
10u
} else { option::get(uint::parse_buf(str::bytes(args[1]), 10u)) };
let i = 0u;
2012-01-06 20:55:56 -08:00
while i < n { task::spawn {|| f(n); }; i += 1u; }
}