about summary refs log tree commit diff
path: root/src/test/bench/task-perf-spawnalot.rs
blob: 3b9b9a0a05bfb577f1cea78d3b87a973b58f9b4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std;
import vec;
import task;
import uint;
import str;

fn f(&&n: uint) {
    let i = 0u;
    while i < n {
        task::join(task::spawn_joinable((), g));
        i += 1u;
    }
}

fn g(&&_i: ()) { }

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; }
}