Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sbt interactive session halts in case of jmh error #107

Open
f1yegor opened this issue Feb 10, 2017 · 1 comment
Open

Sbt interactive session halts in case of jmh error #107

f1yegor opened this issue Feb 10, 2017 · 1 comment

Comments

@f1yegor
Copy link

f1yegor commented Feb 10, 2017

I run interactive sbt session and start jmh benchmark that contains some errors.
The session halts on error.
Is it possible to keep session running?

sbt
jmh:run
[info] Done packaging.
@TearDown annotation is placed within the class not having @State annotation. This has no behavioral effect, and prohibited.
[org.openjdk.jmh.generators.reflection.RFMethodInfo@4234de75]

Sample code to reproduce:

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

object TestBenchmark {
@State(Scope.Benchmark)
class BenchmarkState {
@Param(Array("25", "50", "100", "1000"))
var elementsCount: Int = 0
var items: Seq[Int] = _
}
@Setup
def setup(state: BenchmarkState): Unit = {
state.items = (0 until state.elementsCount)
}
}
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@BenchmarkMode(Array(Mode.AverageTime))
@OutputTimeUnit(value = TimeUnit.MICROSECONDS)
class TestBenchmark {
import TestBenchmark._
@Benchmark
def benchmarkSize(state: BenchmarkState): Unit = {
state.items.size
}
}
@jiminhsieh
Copy link

@f1yegor It seems no one would write like this way. There are some examples that you could see how to write with JMH. ListBenchmark.scala from Scala's repository or TestBenchmark.scal from this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants