Add a task spawning benchmark
This is the kind of workload that the test runner generates - lots of tiny little tasks - and currently it leaves the CPU underutilized.
This commit is contained in:
parent
6657e729de
commit
ec46f07e6e
1 changed files with 29 additions and 0 deletions
29
src/test/bench/task-perf-spawnalot.rs
Normal file
29
src/test/bench/task-perf-spawnalot.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use std;
|
||||
import std::vec;
|
||||
import std::task;
|
||||
import std::uint;
|
||||
import std::str;
|
||||
|
||||
fn f(n: uint) {
|
||||
let i = 0u;
|
||||
while i < n {
|
||||
task::join(spawn g());
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
|
||||
fn g() {}
|
||||
|
||||
fn main(args: vec[str]) {
|
||||
|
||||
let n = if vec::len(args) < 2u {
|
||||
10u
|
||||
} else {
|
||||
uint::parse_buf(str::bytes(args.(1)), 10u)
|
||||
};
|
||||
let i = 0u;
|
||||
while i < n {
|
||||
spawn f(n);
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue