diff options
Diffstat (limited to 'core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala')
-rwxr-xr-x | core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala b/core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala new file mode 100755 index 0000000..4141b37 --- /dev/null +++ b/core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala @@ -0,0 +1,26 @@ +package com.rockymadden.stringmetric.phonetic + +import com.google.caliper.Param +import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner} +import scala.util.Random + +final class RefinedNysiisAlgorithmBenchmark extends CaliperBenchmark { + @Param(Array("0", "1", "2", "4", "8", "16")) + var length: Int = _ + + var string: String = _ + var charArray: Array[Char] = _ + + override protected def setUp() { + string = Random.alphanumeric.filter(_ > '9').take(length).mkString + charArray = string.toCharArray + } + + def timeComputeWithCharArray(reps: Int) = run(reps) { + RefinedNysiisAlgorithm.compute(charArray) + } + + def timeComputeWithString(reps: Int) = run(reps) { + RefinedNysiisAlgorithm.compute(string) + } +} |