diff --git a/benchmark/src/main/scala/breeze/benchmark/BreezeBenchmark.scala b/benchmark/src/main/scala/breeze/benchmark/BreezeBenchmark.scala index e997ae2c7..c57effa01 100644 --- a/benchmark/src/main/scala/breeze/benchmark/BreezeBenchmark.scala +++ b/benchmark/src/main/scala/breeze/benchmark/BreezeBenchmark.scala @@ -18,6 +18,7 @@ package breeze.benchmark +import breeze.stats.distributions.RandBasis import com.google.caliper.Benchmark import com.google.caliper.runner.CaliperMain @@ -25,6 +26,7 @@ import com.google.caliper.runner.CaliperMain * Extend this to create an actual benchmarking class. */ trait BreezeBenchmark { + implicit val randBasis: RandBasis = RandBasis.mt0 /** * Sugar to run 'f' for 'reps' number of times. diff --git a/benchmark/src/main/scala/breeze/linalg/DenseMatrixBenchmark.scala b/benchmark/src/main/scala/breeze/linalg/DenseMatrixBenchmark.scala index cb7bd933d..18c715626 100644 --- a/benchmark/src/main/scala/breeze/linalg/DenseMatrixBenchmark.scala +++ b/benchmark/src/main/scala/breeze/linalg/DenseMatrixBenchmark.scala @@ -8,7 +8,7 @@ import breeze.macros._ object DenseMatrixBenchmark extends MyRunner(classOf[DenseMatrixBenchmark]) trait BuildsRandomMatrices { - private val uniform = Uniform(0, 1) + private val uniform = Uniform(0, 1)(RandBasis.mt0) def randomMatrix(m: Int, n: Int, transpose: Boolean = false): DenseMatrix[Double] = { if (!transpose) { DenseMatrix.rand[Double](m, n) diff --git a/benchmark/src/main/scala/breeze/linalg/DenseVectorBenchmark.scala b/benchmark/src/main/scala/breeze/linalg/DenseVectorBenchmark.scala index dc98db5b5..d347e0199 100644 --- a/benchmark/src/main/scala/breeze/linalg/DenseVectorBenchmark.scala +++ b/benchmark/src/main/scala/breeze/linalg/DenseVectorBenchmark.scala @@ -7,14 +7,14 @@ import breeze.macros._ object DenseVectorBenchmark extends MyRunner(classOf[DenseVectorBenchmark]) trait BuildsRandomVectors { - private val uniform = Uniform(0, 1) + private val uniform = Uniform(0, 1)(RandBasis.mt0) def randomArray(size: Int, offset: Int = 0, stride: Int = 1): DenseVector[Double] = { require(offset >= 0) require(stride >= 1) val result = new DenseVector(new Array[Double](offset + stride * size), offset, stride, size) var i = 0 while (i < size) { - result.unsafeUpdate(i, uniform.draw()) + result.update(i, uniform.draw()) i += 1 } result @@ -83,7 +83,7 @@ class DenseVectorBenchmark extends BreezeBenchmark with BuildsRandomVectors { def timeValueAt(reps: Int) = valueAtBench(reps, 1024 * 8, 1) def timeValueAtStride4(reps: Int) = valueAtBench(reps, 1024 * 8, 4) - + def updateBench(reps: Int, size: Int, stride: Int) = runWith(reps, { randomArray(size, stride = stride) })(arr => { var i = 0 @@ -101,7 +101,7 @@ class DenseVectorBenchmark extends BreezeBenchmark with BuildsRandomVectors { runWith(reps, { randomArray(size, stride = stride) })(arr => { var i = 0 while (i < arr.size) { - arr.unsafeUpdate(i, i.toDouble) + arr.update(i, i.toDouble) i += 1 } arr