diff --git a/benchmarks/src/main/scala/org/broadinstitute/dsde/firecloud/utils/TsvFormatterBenchmark.scala b/benchmarks/src/main/scala/org/broadinstitute/dsde/firecloud/utils/TsvFormatterBenchmark.scala index 6556eb9e3..ee8fbe909 100644 --- a/benchmarks/src/main/scala/org/broadinstitute/dsde/firecloud/utils/TsvFormatterBenchmark.scala +++ b/benchmarks/src/main/scala/org/broadinstitute/dsde/firecloud/utils/TsvFormatterBenchmark.scala @@ -1,20 +1,31 @@ package org.broadinstitute.dsde.firecloud.utils -import org.openjdk.jmh.annotations.Benchmark +import org.broadinstitute.dsde.firecloud.utils.TsvFormatterBenchmark.Inputs +import org.openjdk.jmh.annotations.{Benchmark, Scope, State} import org.openjdk.jmh.infra.Blackhole +object TsvFormatterBenchmark { + + @State(Scope.Thread) + class Inputs { + val inputNoTab = "foo" + val inputWithTab = "foo\tbar" + } + +} + class TsvFormatterBenchmark { @Benchmark - def tsvSafeStringNoTab(blackHole: Blackhole): String = { - val result = TSVFormatter.tsvSafeString("foo") + def tsvSafeStringNoTab(blackHole: Blackhole, inputs: Inputs): String = { + val result = TSVFormatter.tsvSafeString(inputs.inputNoTab) blackHole.consume(result) result } @Benchmark - def tsvSafeStringWithTab(blackHole: Blackhole): String = { - val result = TSVFormatter.tsvSafeString("foo\tbar") + def tsvSafeStringWithTab(blackHole: Blackhole, inputs: Inputs): String = { + val result = TSVFormatter.tsvSafeString(inputs.inputWithTab) blackHole.consume(result) result }