Skip to content

Instantly share code, notes, and snippets.

@nremond
Created October 16, 2013 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nremond/7015500 to your computer and use it in GitHub Desktop.
Save nremond/7015500 to your computer and use it in GitHub Desktop.
class NicoBench extends AbstractBenchmark {
val cacheUri = new ConcurrentHashMap[URI, Int]
@Test
@BenchmarkOptions(benchmarkRounds = 20000, warmupRounds = 5000, concurrency = 8)
def uri_hashcode() {
val uri = new URI("http://fake.com/" + ThreadLocalRandom.current.nextInt(0, 1000))
cacheUri.putIfAbsent(uri, 123)
cacheUri.get(uri)
}
val cacheUriString = new ConcurrentHashMap[String, Int]
@Test
@BenchmarkOptions(benchmarkRounds = 20000, warmupRounds = 5000, concurrency = 8)
def uri_toString_hashcode() {
val uri = new URI("http://fake.com/" + ThreadLocalRandom.current.nextInt(0, 1000)).toString
cacheUriString.putIfAbsent(uri, 123)
cacheUriString.get(uri)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment