forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Widen mutable.BitSet operations to accept any BitSet
Add other optimizations for: * mutable.BitSeta.addAll * Fix implementation of mutable.BitSet.subsetOf
- Loading branch information
Showing
4 changed files
with
178 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
test/benchmarks/src/main/scala/scala/collection/mutable/BitSetBenchmark.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package scala.collection.mutable | ||
|
||
import org.openjdk.jmh.annotations._ | ||
import org.openjdk.jmh.infra._ | ||
import java.util.concurrent.TimeUnit | ||
|
||
import scala.collection.mutable | ||
|
||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@Fork(1) | ||
@Threads(1) | ||
@Warmup(iterations = 6) | ||
@Measurement(iterations = 6) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
@State(Scope.Benchmark) | ||
class BitSetBenchmark { | ||
@Param(Array("0", "3", "5", "10", "1000", "1000000")) | ||
var size: Int = _ | ||
|
||
val bitSet = (1 to 1000).to(mutable.BitSet) | ||
|
||
var bs: mutable.BitSet = _ | ||
|
||
var range: Range = _ | ||
|
||
val clones: Array[mutable.BitSet] = new Array(100) | ||
|
||
@Setup(Level.Iteration) def initializeRange(): Unit = { | ||
range = (10 to (10 + size)) | ||
} | ||
@Setup(Level.Invocation) def initializeClones(): Unit = { | ||
(0 until 100) foreach (i => clones(i) = bitSet.clone()) | ||
} | ||
|
||
@Benchmark def addAll(bh: Blackhole): Unit = { | ||
clones.foreach{ c => | ||
bh consume c.addAll(range) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters