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

25 lines
448 B
Rust
Raw Normal View History

use std;
2011-08-15 16:38:23 -07:00
import std::vec;
import std::task;
import std::uint;
import std::str;
fn# f(&&n: uint) {
let i = 0u;
while i < n {
task::join(task::spawn_joinable2((), g));
2011-09-02 15:34:58 -07:00
i += 1u;
}
}
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::spawn2(copy n, f); i += 1u; }
}