From ec46f07e6e41d91b86f5fee8cd0925934a0f7b60 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 29 Jul 2011 22:09:25 -0700 Subject: [PATCH] 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. --- src/test/bench/task-perf-spawnalot.rs | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/bench/task-perf-spawnalot.rs diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs new file mode 100644 index 000000000000..0c63661ebae9 --- /dev/null +++ b/src/test/bench/task-perf-spawnalot.rs @@ -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; + } +} \ No newline at end of file