summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2012-02-03 15:05:56 +0100
committerAleksandar Prokopec <axel22@gmail.com>2012-02-03 15:15:57 +0100
commit86946630e9a1240fb9a378b2ec62e78b521f4320 (patch)
treeb731aacfed51a534bca9ca1c3eae21f960af765e /test
parent2d9dfe3077fa2b43a336548cad98a522215c52a9 (diff)
downloadscala-86946630e9a1240fb9a378b2ec62e78b521f4320.tar.gz
scala-86946630e9a1240fb9a378b2ec62e78b521f4320.tar.bz2
scala-86946630e9a1240fb9a378b2ec62e78b521f4320.zip
Fix some issues in parallel Ctrie.
This change resolves some issues with ParCtrie splitters and their `remaining` method, which currently evaluates the size of the Ctrie. Since this is still not done lazily, nor in parallel, it has a certain cost, which is unacceptable. Change #1: The `shouldSplitFurther` method is by default implemented by calling the `remaining` method. This method now forwards the call to the same method in the splitter which is by default implemented in the same way as before, but can be overridden by custom collections such as the ParCtrie. Change #2: ParCtrie splitter now has a `level` member which just counts how many times the method has been split. This information is used to override the default `shouldSplitFurther` implementation. Change #3: The tasks and splitters rely heavily on the `remaining` method in the splitter for most operations. There is an additional method called `isRemainingCheap` which returns true by default, but can be overridden by custom collections such as the `Ctrie`.
Diffstat (limited to 'test')
-rw-r--r--test/benchmarking/ParCtrie-map.scala21
-rw-r--r--test/benchmarking/TreeSetInsert.scala2
2 files changed, 23 insertions, 0 deletions
diff --git a/test/benchmarking/ParCtrie-map.scala b/test/benchmarking/ParCtrie-map.scala
new file mode 100644
index 0000000000..c8de99f33e
--- /dev/null
+++ b/test/benchmarking/ParCtrie-map.scala
@@ -0,0 +1,21 @@
+
+
+
+import collection.parallel.mutable.ParCtrie
+
+
+
+object Map extends testing.Benchmark {
+ val length = sys.props("length").toInt
+ val par = sys.props("par").toInt
+ val parctrie = ParCtrie((0 until length) zip (0 until length): _*)
+
+ collection.parallel.ForkJoinTasks.defaultForkJoinPool.setParallelism(par)
+
+ def run = {
+ parctrie map {
+ kv => kv
+ }
+ }
+}
+
diff --git a/test/benchmarking/TreeSetInsert.scala b/test/benchmarking/TreeSetInsert.scala
index 9ede8aedc5..23444aa305 100644
--- a/test/benchmarking/TreeSetInsert.scala
+++ b/test/benchmarking/TreeSetInsert.scala
@@ -33,6 +33,7 @@ object JavaUtilTS extends testing.Benchmark {
}
}
+
object MutableTS extends testing.Benchmark {
val length = sys.props("length").toInt
var data: Array[Dummy] = (0 until length) map { a => new Dummy(a) } toArray
@@ -50,6 +51,7 @@ object MutableTS extends testing.Benchmark {
}
}
+
object ImmutableTS extends testing.Benchmark {
val length = sys.props("length").toInt
var data: Array[Dummy] = (0 until length) map { a => new Dummy(a) } toArray