about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-07-29 22:09:25 -0700
committerBrian Anderson <banderson@mozilla.com>2011-07-29 22:45:01 -0700
commitec46f07e6e41d91b86f5fee8cd0925934a0f7b60 (patch)
treea5b87c9ea373152f5a3364b5392fc3e92e4ca189
parent6657e729de2d4544d4f014091ef05878937895dc (diff)
downloadrust-ec46f07e6e41d91b86f5fee8cd0925934a0f7b60.tar.gz
rust-ec46f07e6e41d91b86f5fee8cd0925934a0f7b60.zip
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.
-rw-r--r--src/test/bench/task-perf-spawnalot.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs
new file mode 100644
index 00000000000..0c63661ebae
--- /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