diff options
Diffstat (limited to 'core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala')
-rwxr-xr-x | core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala b/core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala deleted file mode 100755 index 7707019..0000000 --- a/core/src/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.rockymadden.stringmetric.phonetic - -import com.google.caliper.Param -import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner} -import scala.annotation.tailrec -import scala.util.Random - -final class SoundexMetricBenchmark extends CaliperBenchmark { - @Param(Array("0", "1", "2", "4", "8", "16")) - var length: Int = _ - - var string1: String = _ - var charArray1: Array[Char] = _ - var string2: String = _ - var charArray2: Array[Char] = _ - - override protected def setUp() { - @tailrec - def random(l: Int, ps: String = null): String = - if (l == 0) "" - else { - val s = Random.alphanumeric.filter(_ > '9').take(l).mkString - - if (ps == null || s != ps) s - else random(l, ps) - } - - string1 = random(length) - string2 = random(length, string1) - charArray1 = string1.toCharArray - charArray2 = string2.toCharArray - } - - def timeCompareWithDifferentCharArrays(reps: Int) = run(reps) { - SoundexMetric.compare(charArray1, charArray2) - } - - def timeCompareWithDifferentStrings(reps: Int) = run(reps) { - SoundexMetric.compare(string1, string2) - } - - def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) { - SoundexMetric.compare(charArray1, charArray1) - } - - def timeCompareWithIdenticalStrings(reps: Int) = run(reps) { - SoundexMetric.compare(string1, string1) - } -} |