Skip to content

Commit

Permalink
Added additional sbt settings for controlling JMH.
Browse files Browse the repository at this point in the history
Signed-off-by: Simeon H.K. fitch <fitch@astraea.io>
  • Loading branch information
metasim authored and echeipesh committed Sep 29, 2017
1 parent b1ae13f commit a8dc87c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
30 changes: 29 additions & 1 deletion bench/build.sbt
Expand Up @@ -8,16 +8,44 @@ enablePlugins(JmhPlugin)
val jmhOutputFormat = settingKey[String]("Output format: {text|csv|scsv|json|latex}")
jmhOutputFormat := "csv"

val jmhOutputDir = settingKey[File]("Directory for writing JMH results")
jmhOutputDir := target.value

val jmhFileRegex = settingKey[Regex]("Filename regular expression for selecting files to benchmark")
jmhFileRegex := ".*Bench.*".r

val jmhThreads = settingKey[Int]("Number of worker threads")
jmhThreads := 1

val jmhFork = settingKey[Int]("How many times to fork a single benchmark")
jmhFork := 1

val jmhIterations = settingKey[Int]("Number of measurement iterations to do")
jmhIterations := 10

val jmhWarmupIterations = settingKey[Int]("Number of warmup iterations to do.")
jmhWarmupIterations := math.max(jmhIterations.value/2, 5)

val jmhTimeUnit = settingKey[String]("Benchmark results unit: {m|s|ms|us|ns}.")
jmhTimeUnit := "ms"


val jmhRun = Def.taskDyn {
val rf = jmhOutputFormat.value
def timestamp = new SimpleDateFormat("yyyyMMdd").format(new Date())
val dir = jmhOutputDir.value
IO.createDirectory(dir)

val rff = target.value / s"jmh-results-$timestamp.${jmhOutputFormat.value}"
val pat = jmhFileRegex.value.toString

val args = s" -rf $rf -rff $rff $pat"
val t = jmhThreads.value
val f = jmhFork.value
val i = jmhIterations.value
val wi = jmhWarmupIterations.value
val tu = jmhTimeUnit.value

val args = s" -t $t -f $f -i $i -wi $wi -tu $tu -rf $rf -rff $rff $pat"
(run in Jmh).toTask(args)
}

Expand Down
@@ -1,18 +1,22 @@
package geotrellis.spark.io.index


import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations._

@BenchmarkMode(Array(Mode.AverageTime))
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5)
@Measurement(iterations = 10)
@Fork(1)
@Threads(1)
@State(Scope.Thread)
class MergeQueueBench {
val queue = new MergeQueue()

var queue: MergeQueue = _

@Setup
def setup() = {
queue = new MergeQueue()
}

@TearDown
def tearDown() = {
queue = null
}

@Benchmark
def mergeOrderedDense = {
Expand Down

0 comments on commit a8dc87c

Please sign in to comment.