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

25 lines
424 B
Rust
Raw Normal View History

use std;
import vec;
import task;
import uint;
import str;
2011-10-20 20:34:04 -07:00
fn f(&&n: uint) {
let i = 0u;
while i < n {
task::join(task::spawn_joinable((), g));
2011-09-02 15:34:58 -07:00
i += 1u;
}
}
2011-10-20 20:34:04 -07:00
fn g(&&_i: ()) { }
2011-09-02 15:34:58 -07:00
fn main(args: [str]) {
let n =
if vec::len(args) < 2u {
10u
} else { uint::parse_buf(str::bytes(args[1]), 10u) };
let i = 0u;
while i < n { task::spawn(copy n, f); i += 1u; }
}