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

30 lines
494 B
Rust
Raw Normal View History

use std;
import std::ivec;
import std::task;
import std::uint;
import std::str;
fn f(n: uint) {
let i = 0u;
while i < n {
2011-08-13 16:03:28 -07:00
task::join_id(task::_spawn(bind g()));
i += 1u;
}
}
fn g() {}
fn main(args: vec[str]) {
2011-08-11 21:37:27 -07:00
let iargs = ivec::from_vec(args);
let n = if ivec::len(iargs) < 2u {
10u
} else {
2011-08-11 23:36:43 -07:00
uint::parse_buf(str::bytes(iargs.(1)), 10u)
};
let i = 0u;
while i < n {
2011-08-13 16:03:28 -07:00
task::_spawn(bind f(n));
i += 1u;
}
}