Skip to content

Instantly share code, notes, and snippets.

@ochoto
Forked from ktoso/to-stack-or-not-to-stack.scala
Last active August 29, 2015 14:16
Show Gist options
  • Save ochoto/706c650cc3be3b883500 to your computer and use it in GitHub Desktop.
Save ochoto/706c650cc3be3b883500 to your computer and use it in GitHub Desktop.
package whoop.whoop
import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations._
import scala.util.control.NoStackTrace
@State(Scope.Benchmark)
@BenchmarkMode(Array(Mode.AverageTime))
@OutputTimeUnit(TimeUnit.MICROSECONDS)
class NoStackTraceBenchmark {
class Ex extends RuntimeException("")
class ExNo extends RuntimeException("") with NoStackTrace
@Benchmark def normal = new Ex
@Benchmark def nostack = new ExNo
/*
just sayin'...
Benchmark Mode Cnt Score Error Units
NoStackTraceBenchmark.normal avgt 40 1.539 ± 0.140 us/op
NoStackTraceBenchmark.nostack avgt 40 0.010 ± 0.001 us/op
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment