-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIT extract a helper trait for JMH tests
- Loading branch information
Showing
2 changed files
with
34 additions
and
31 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
modules/integration/src/test/scala/scala/cli/integration/JmhSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package scala.cli.integration | ||
|
||
trait JmhSuite { _: ScalaCliSuite => | ||
protected lazy val simpleInputs: TestInputs = TestInputs( | ||
os.rel / "benchmark.scala" -> | ||
s"""package bench | ||
| | ||
|import java.util.concurrent.TimeUnit | ||
|import org.openjdk.jmh.annotations._ | ||
| | ||
|@BenchmarkMode(Array(Mode.AverageTime)) | ||
|@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
|@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) | ||
|@Measurement(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS) | ||
|@Fork(0) | ||
|class Benchmarks { | ||
| | ||
| @Benchmark | ||
| def foo(): Unit = { | ||
| (1L to 10000000L).sum | ||
| } | ||
| | ||
|} | ||
|""".stripMargin | ||
) | ||
protected lazy val expectedInOutput = """Result "bench.Benchmarks.foo":""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters