Created
May 2, 2012 18:08
-
-
Save paulitex/2578816 to your computer and use it in GitHub Desktop.
Mutable Map test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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