Benchmarking plugin for SBT
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

SBT Benchmark Plugin

SBT plugin to support separate test sources for benchmarking. Adds support for src/benchmark as additional test sources.


Plugins file:

import sbt._

class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
  val guardian = "Guardian GitHub" at ""
  val solr = "" % "sbt-benchmark-plugin" % "0.1"

Project file:

import sbt._

class MyProject(info: ProjectInfo) extends DefaultProject(info) with Benchmarks {

Put your benchmark tests in src/benchmark/scala. This is used as test sources in the following new actions:

  • benchmark: Run benchmarks in src/benchmark
  • benchmark-compile: Compile benchmarks in src/benchmark
  • benchmark-only: Runs the benchmarks provided as arguments.

Sample Benchmarks

A simple benchmark test might look like the following:


import org.scalatest.FunSuite
import scala.testing.Benchmark

case class SampleBenchmark() extends Benchmark {
  def run = {
    Thread sleep 5000

class SampleBenchmarkTest extends FunSuite {
  test("SampleBenchmark") {
    val timings = SampleBenchmark() run 5
    println("Total execution time: " + timings.sum)
    println("Mean execution time: " + (timings.sum/timings.length))