Skip to content

Instantly share code, notes, and snippets.

@paulitex
Created May 2, 2012 18:08
Show Gist options
  • Save paulitex/2578816 to your computer and use it in GitHub Desktop.
Save paulitex/2578816 to your computer and use it in GitHub Desktop.
Mutable Map test
object Test extends App {
val runs = 100
val puts = 100
var acc = 0L;
for (k <- (0 until runs)) {
val map = collection.mutable.Map[String, Int]()
val start = System.currentTimeMillis
for (i <- (0 until 100000)) {
map += (i.toString -> i)
}
acc += System.currentTimeMillis - start
}
println("Scala Hash Map: " + acc / runs)
acc = 0L;
for (k <- (0 until runs)) {
var map = new java.util.HashMap[String, Int]()
val start = System.currentTimeMillis
for (i <- (0 until 100000)) {
map.put(i.toString, i)
}
acc += System.currentTimeMillis - start
}
println("Java Hash Map: " + acc / runs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment