summaryrefslogtreecommitdiff
path: root/stringmetric-core/source/benchmark/scala/com/rockymadden
diff options
context:
space:
mode:
Diffstat (limited to 'stringmetric-core/source/benchmark/scala/com/rockymadden')
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperBenchmark.scala7
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperRunner.scala7
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala32
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala32
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala32
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala32
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala32
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaccardMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala58
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/OverlapMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala55
-rwxr-xr-xstringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerBenchmark.scala35
23 files changed, 1037 insertions, 0 deletions
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperBenchmark.scala
new file mode 100755
index 0000000..55a6238
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperBenchmark.scala
@@ -0,0 +1,7 @@
+package com.rockymadden.stringmetric
+
+import com.google.caliper.SimpleBenchmark
+
+trait CaliperBenchmark extends SimpleBenchmark {
+ def run(reps: Int)(code: => Unit) = (0 until reps).foreach(i => code)
+} \ No newline at end of file
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperRunner.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperRunner.scala
new file mode 100755
index 0000000..4474a8d
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/CaliperRunner.scala
@@ -0,0 +1,7 @@
+package com.rockymadden.stringmetric
+
+import com.google.caliper.{Benchmark, Runner}
+
+abstract class CaliperRunner(private[this] val suite: java.lang.Class[_ <: Benchmark]) {
+ def main(args: Array[String]): Unit = Runner.main(suite, args)
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala
new file mode 100755
index 0000000..bfc17f2
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala
@@ -0,0 +1,32 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.util.Random
+
+final class MetaphoneAlgorithmBenchmark extends CaliperBenchmark {
+ import MetaphoneAlgorithmBenchmark.Algorithm
+
+ @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) {
+ Algorithm.compute(charArray)
+ }
+
+ def timeComputeWithString(reps: Int) = run(reps) {
+ Algorithm.compute(string)
+ }
+}
+
+object MetaphoneAlgorithmBenchmark extends CaliperRunner(classOf[MetaphoneAlgorithmBenchmark]) {
+ private final val Algorithm = MetaphoneAlgorithm()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala
new file mode 100755
index 0000000..147ab54
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala
@@ -0,0 +1,55 @@
+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 MetaphoneMetricBenchmark extends CaliperBenchmark {
+ import MetaphoneMetricBenchmark.Metric
+
+ @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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object MetaphoneMetricBenchmark extends CaliperRunner(classOf[MetaphoneMetricBenchmark]) {
+ private final val Metric = MetaphoneMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala
new file mode 100755
index 0000000..79f9e16
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala
@@ -0,0 +1,32 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.util.Random
+
+final class NysiisAlgorithmBenchmark extends CaliperBenchmark {
+ import NysiisAlgorithmBenchmark.Algorithm
+
+ @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) {
+ Algorithm.compute(charArray)
+ }
+
+ def timeComputeWithString(reps: Int) = run(reps) {
+ Algorithm.compute(string)
+ }
+}
+
+object NysiisAlgorithmBenchmark extends CaliperRunner(classOf[NysiisAlgorithmBenchmark]) {
+ private final val Algorithm = NysiisAlgorithm()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala
new file mode 100755
index 0000000..620d054
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala
@@ -0,0 +1,55 @@
+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 NysiisMetricBenchmark extends CaliperBenchmark {
+ import NysiisMetricBenchmark.Metric
+
+ @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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object NysiisMetricBenchmark extends CaliperRunner(classOf[NysiisMetricBenchmark]) {
+ private final val Metric = NysiisMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala
new file mode 100755
index 0000000..885bc3a
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala
@@ -0,0 +1,32 @@
+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 {
+ import RefinedNysiisAlgorithmBenchmark.Algorithm
+
+ @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) {
+ Algorithm.compute(charArray)
+ }
+
+ def timeComputeWithString(reps: Int) = run(reps) {
+ Algorithm.compute(string)
+ }
+}
+
+object RefinedNysiisAlgorithmBenchmark extends CaliperRunner(classOf[RefinedNysiisAlgorithmBenchmark]) {
+ private final val Algorithm = RefinedNysiisAlgorithm()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala
new file mode 100755
index 0000000..d0da4e5
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala
@@ -0,0 +1,55 @@
+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 RefinedNysiisMetricBenchmark extends CaliperBenchmark {
+ import RefinedNysiisMetricBenchmark.Metric
+
+ @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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object RefinedNysiisMetricBenchmark extends CaliperRunner(classOf[RefinedNysiisMetricBenchmark]) {
+ private final val Metric = RefinedNysiisMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala
new file mode 100755
index 0000000..99aa3df
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala
@@ -0,0 +1,32 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.util.Random
+
+final class RefinedSoundexAlgorithmBenchmark extends CaliperBenchmark {
+ import RefinedSoundexAlgorithmBenchmark.Algorithm
+
+ @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) {
+ Algorithm.compute(charArray)
+ }
+
+ def timeComputeWithString(reps: Int) = run(reps) {
+ Algorithm.compute(string)
+ }
+}
+
+object RefinedSoundexAlgorithmBenchmark extends CaliperRunner(classOf[RefinedSoundexAlgorithmBenchmark]) {
+ private final val Algorithm = RefinedSoundexAlgorithm()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala
new file mode 100755
index 0000000..8e24650
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala
@@ -0,0 +1,55 @@
+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 RefinedSoundexMetricBenchmark extends CaliperBenchmark {
+ import RefinedSoundexMetricBenchmark.Metric
+
+ @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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object RefinedSoundexMetricBenchmark extends CaliperRunner(classOf[RefinedSoundexMetricBenchmark]) {
+ private final val Metric = RefinedSoundexMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala
new file mode 100755
index 0000000..5c195a6
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala
@@ -0,0 +1,32 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.util.Random
+
+final class SoundexAlgorithmBenchmark extends CaliperBenchmark {
+ import SoundexAlgorithmBenchmark.Algorithm
+
+ @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) {
+ Algorithm.compute(charArray)
+ }
+
+ def timeComputeWithString(reps: Int) = run(reps) {
+ Algorithm.compute(string)
+ }
+}
+
+object SoundexAlgorithmBenchmark extends CaliperRunner(classOf[SoundexAlgorithmBenchmark]) {
+ private final val Algorithm = SoundexAlgorithm()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala
new file mode 100755
index 0000000..6534d72
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala
@@ -0,0 +1,55 @@
+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 {
+ import SoundexMetricBenchmark.Metric
+
+ @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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object SoundexMetricBenchmark extends CaliperRunner(classOf[SoundexMetricBenchmark]) {
+ private final val Metric = SoundexMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala
new file mode 100755
index 0000000..88f5d4c
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class DiceSorensenMetricBenchmark extends CaliperBenchmark {
+ import DiceSorensenMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)(2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)(2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)(2)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)(2)
+ }
+}
+
+object DiceSorensenMetricBenchmark extends CaliperRunner(classOf[DiceSorensenMetricBenchmark]) {
+ private final val Metric = DiceSorensenMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala
new file mode 100755
index 0000000..60ef7d4
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class HammingMetricBenchmark extends CaliperBenchmark {
+ import HammingMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object HammingMetricBenchmark extends CaliperRunner(classOf[HammingMetricBenchmark]) {
+ private final val Metric = HammingMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaccardMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaccardMetricBenchmark.scala
new file mode 100755
index 0000000..3f6a59f
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaccardMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class JaccardMetricBenchmark extends CaliperBenchmark {
+ import JaccardMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)(2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)(2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)(2)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)(2)
+ }
+}
+
+object JaccardMetricBenchmark extends CaliperRunner(classOf[JaccardMetricBenchmark]) {
+ private final val Metric = JaccardMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala
new file mode 100755
index 0000000..c9c9b2c
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class JaroMetricBenchmark extends CaliperBenchmark {
+ import JaroMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object JaroMetricBenchmark extends CaliperRunner(classOf[JaroMetricBenchmark]) {
+ private final val Metric = JaroMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala
new file mode 100755
index 0000000..b3da154
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class JaroWinklerMetricBenchmark extends CaliperBenchmark {
+ import JaroWinklerMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object JaroWinklerMetricBenchmark extends CaliperRunner(classOf[JaroWinklerMetricBenchmark]) {
+ private final val Metric = JaroWinklerMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala
new file mode 100755
index 0000000..d47e138
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class LevenshteinMetricBenchmark extends CaliperBenchmark {
+ import LevenshteinMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object LevenshteinMetricBenchmark extends CaliperRunner(classOf[LevenshteinMetricBenchmark]) {
+ private final val Metric = LevenshteinMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala
new file mode 100755
index 0000000..4250e66
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala
@@ -0,0 +1,58 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class NGramMetricBenchmark extends CaliperBenchmark {
+ import NGramMetricBenchmark.Metric
+
+ @Param(Array("0", "1", "2", "4", "8", "16"))
+ var length: Int = _
+
+ @Param(Array("2", "3"))
+ var n: 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.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) {
+ Metric.compare(charArray1, charArray2)(n)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)(n)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)(n)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)(n)
+ }
+}
+
+object NGramMetricBenchmark extends CaliperRunner(classOf[NGramMetricBenchmark]) {
+ private final val Metric = NGramMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/OverlapMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/OverlapMetricBenchmark.scala
new file mode 100755
index 0000000..4d7ce0a
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/OverlapMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class OverlapMetricBenchmark extends CaliperBenchmark {
+ import OverlapMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)(2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)(2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)(2)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)(2)
+ }
+}
+
+object OverlapMetricBenchmark extends CaliperRunner(classOf[OverlapMetricBenchmark]) {
+ private final val Metric = OverlapMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala
new file mode 100755
index 0000000..edc1527
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class RatcliffObershelpMetricBenchmark extends CaliperBenchmark {
+ import RatcliffObershelpMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)
+ }
+}
+
+object RatcliffObershelpMetricBenchmark extends CaliperRunner(classOf[RatcliffObershelpMetricBenchmark]) {
+ private final val Metric = RatcliffObershelpMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala
new file mode 100755
index 0000000..b511654
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala
@@ -0,0 +1,55 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.annotation.tailrec
+import scala.util.Random
+
+final class WeightedLevenshteinMetricBenchmark extends CaliperBenchmark {
+ import WeightedLevenshteinMetricBenchmark.Metric
+
+ @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.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) {
+ Metric.compare(charArray1, charArray2)(1, 1, 1)
+ }
+
+ def timeCompareWithDifferentStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string2)(1, 1, 1)
+ }
+
+ def timeCompareWithIdenticalCharArrays(reps: Int) = run(reps) {
+ Metric.compare(charArray1, charArray1)(1, 1, 1)
+ }
+
+ def timeCompareWithIdenticalStrings(reps: Int) = run(reps) {
+ Metric.compare(string1, string1)(1, 1, 1)
+ }
+}
+
+object WeightedLevenshteinMetricBenchmark extends CaliperRunner(classOf[WeightedLevenshteinMetricBenchmark]) {
+ private final val Metric = WeightedLevenshteinMetric()
+}
diff --git a/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerBenchmark.scala b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerBenchmark.scala
new file mode 100755
index 0000000..7e62662
--- /dev/null
+++ b/stringmetric-core/source/benchmark/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerBenchmark.scala
@@ -0,0 +1,35 @@
+package com.rockymadden.stringmetric.tokenization
+
+import com.google.caliper.Param
+import com.rockymadden.stringmetric.{CaliperBenchmark, CaliperRunner}
+import scala.util.Random
+
+final class NGramTokenizerBenchmark extends CaliperBenchmark {
+ import NGramTokenizerBenchmark.Tokenizer
+
+ @Param(Array("0", "1", "2", "4", "8", "16"))
+ var length: Int = _
+
+ @Param(Array("2", "3"))
+ var n: Int = _
+
+ var string: String = _
+ var charArray: Array[Char] = _
+
+ override protected def setUp() {
+ string = Random.alphanumeric.take(length).mkString
+ charArray = string.toCharArray
+ }
+
+ def timeComputeWithCharArray(reps: Int) = run(reps) {
+ Tokenizer.tokenize(charArray)(n)
+ }
+
+ def timeComputeWithString(reps: Int) = run(reps) {
+ Tokenizer.tokenize(string)(n)
+ }
+}
+
+object NGramTokenizerBenchmark extends CaliperRunner(classOf[NGramTokenizerBenchmark]) {
+ private final val Tokenizer = NGramTokenizer()
+}