Add a benchmark for cross-task kernel memory region synchronization
Vectors are allocated from the kernel's memory region, which has some heinous synchronization. This is a stress test of vector allocation in many tasks.
This commit is contained in:
parent
30447e1091
commit
dabf1be226
1 changed files with 28 additions and 0 deletions
28
src/test/bench/task-perf-vector-party.rs
Normal file
28
src/test/bench/task-perf-vector-party.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Vectors are allocated in the Rust kernel's memory region, use of
|
||||
// which requires some amount of synchronization. This test exercises
|
||||
// that synchronization by spawning a number of tasks and then
|
||||
// allocating and freeing vectors.
|
||||
|
||||
use std;
|
||||
import std::vec;
|
||||
import std::uint;
|
||||
import std::istr;
|
||||
import std::task;
|
||||
|
||||
fn f(n: uint) {
|
||||
for each i in uint::range(0u, n) {
|
||||
let v: [u8] = [];
|
||||
vec::reserve(v, 1000u);
|
||||
}
|
||||
}
|
||||
|
||||
fn main(args: [istr]) {
|
||||
let n = if vec::len(args) < 2u {
|
||||
100u
|
||||
} else {
|
||||
uint::parse_buf(istr::bytes(args[1]), 10u)
|
||||
};
|
||||
for each i in uint::range(0u, 100u) {
|
||||
task::spawn(bind f(n));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue