summaryrefslogblamecommitdiff
path: root/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala
blob: ec8d53c030f52d5a8b1ea2de5e045cf1d64ed9e1 (plain) (tree)
1
2
3
4
                                             

                               
                                                                     














                                                                                  
                                                          


                                                          
                                                       

         
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 {
	@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) {
		RefinedSoundexAlgorithm.compute(charArray)
	}

	def timeComputeWithString(reps: Int) = run(reps) {
		RefinedSoundexAlgorithm.compute(string)
	}
}