rust/src/test/bench/task-perf-vector-party.rs
Marijn Haverbeke 3b5b93221e Remove some semicolons after block calls
The remaining ones can be removed after the next snapshot. (Or
we can let the next pretty-print pass take care of them.)
2011-10-21 14:24:42 +02:00

26 lines
636 B
Rust

// 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::str;
import std::task;
fn f(&&n: uint) {
uint::range(0u, n) {|i|
let v: [u8] = [];
vec::reserve(v, 1000u);
}
}
fn main(args: [str]) {
let n =
if vec::len(args) < 2u {
100u
} else { uint::parse_buf(str::bytes(args[1]), 10u) };
uint::range(0u, 100u) {|i| task::spawn(copy n, f); }
}