rust/src/test/bench/task-perf-vector-party.rs

18 lines
535 B
Rust
Raw Normal View History

// 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.
2011-10-20 22:34:04 -05:00
fn f(&&n: uint) {
uint::range(0u, n) {|i|
let v: [u8] = [];
vec::reserve(v, 1000u);
}
}
2011-09-02 17:34:58 -05:00
fn main(args: [str]) {
let n = if vec::len(args) < 2u { 100u }
else { option::get(uint::from_str(args[1])) };
2012-01-06 22:55:56 -06:00
uint::range(0u, 100u) {|i| task::spawn {|| f(n); };}
2011-09-02 17:34:58 -05:00
}