diff options
author | Aleksandar Prokopec <axel22@gmail.com> | 2012-02-03 15:05:56 +0100 |
---|---|---|
committer | Aleksandar Prokopec <axel22@gmail.com> | 2012-02-03 15:15:57 +0100 |
commit | 86946630e9a1240fb9a378b2ec62e78b521f4320 (patch) | |
tree | b731aacfed51a534bca9ca1c3eae21f960af765e /test/benchmarking/ParCtrie-map.scala | |
parent | 2d9dfe3077fa2b43a336548cad98a522215c52a9 (diff) | |
download | scala-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/benchmarking/ParCtrie-map.scala')
-rw-r--r-- | test/benchmarking/ParCtrie-map.scala | 21 |
1 files changed, 21 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 + } + } +} + |