Skip to content

Instantly share code, notes, and snippets.

@voronaam
Last active August 29, 2015 14:00
Show Gist options
  • Save voronaam/11273582 to your computer and use it in GitHub Desktop.
Save voronaam/11273582 to your computer and use it in GitHub Desktop.
/** Test results:
Benchmark Mode Samples Mean Mean error Units
c.t.MyBenchmark.testString thrpt 200 391517.835 3311.834 ops/ms
c.t.MyBenchmark.testSymbol thrpt 200 36618.384 193.733 ops/ms
*/
package com.test {
import org.openjdk.jmh.annotations.GenerateMicroBenchmark
class MyBenchmark {
def testStringData = "test"
def testSymbolData = 'test
@GenerateMicroBenchmark
def testString(): Any = {
testStringData match {
case "some" => 1L
case "other" => 2L
case "test" => 3L
case _ => 4L
}
}
@GenerateMicroBenchmark
def testSymbol(): Any = {
testSymbolData match {
case 'some => 1L
case 'other => 2L
case 'test => 3L
case _ => 4L
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment