Skip to content

Instantly share code, notes, and snippets.

@ViniciusMiana
Last active December 12, 2015 05:58
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 ViniciusMiana/4725280 to your computer and use it in GitHub Desktop.
Save ViniciusMiana/4725280 to your computer and use it in GitHub Desktop.
A ListMap apply benchmark. Run with: java -server -cp ...../scala/build/pack/lib/scala-library.jar -Dsize=[sizeOfListMap] -Dnreads=[numberOfCallsToApply] ListMapBench [NumberOfRunsOfTheTest]
-Dsize=120 -Dnreads=1000 ListMapBench 10
ListMapBench$ 15 2 2 1 1 0 0 1 1 0
-Dsize=120 -Dnreads=10000 ListMapBench 10
ListMapBench$ 17 4 2 3 3 3 3 3 3 3
-Dsize=120 -Dnreads=100000 ListMapBench 10
ListMapBench$ 29 15 15 13 15 15 18 17 15 15
-Dsize=120 -Dnreads=1000000 ListMapBench 10
ListMapBench$ 123 110 112 113 112 113 109 115 114 114
-Dsize=120 -Dnreads=1000000 ListMapBench 15
ListMapBench$ 124 113 113 115 113 108 114 113 113 113 114 113 113 114 112
-Dsize=120 -Dnreads=10000000 ListMapBench 15
ListMapBench$ 1083 1069 1067 1063 1061 1062 1063 1064 1062 1060 1065 1064 1065 1065 1063
-Dsize=100000 -Dnreads=1000 ListMapBench 10
if-> apply0
ListMapBench$ 27591 27695 27593 27608 26709 22747 21197 21206 21325 21638
try-catch
ListMapBench$ 27433 27606 27615 27573 26640 22152 21173 21097 21101 21337
original
ListMapBench$ 27531 28020 28205 28148 26727 22096 21013 21145 20912 20870
ListMapBench$ 27772 28653 28336 28466 26698 22588 21850 21813 22053 22134
import scala.collection.immutable.ListMap
object ListMapBench extends testing.Benchmark {
val nReads = sys.props("nreads").toInt
val size = sys.props("size").toInt
def listMap = ListMap() ++ ((0 until size) map { t => (t,t) })
def run = {
val l = listMap
var x = 0
while (x < nReads) {
l(x)
x = x + 1
}
}
}
-Dsize=120 -Dnreads=1000 ListMapBench 10
ListMapBench$ 14 3 3 1 1 0 1 0 0 1
-Dsize=120 -Dnreads=1000 ListMapBench 10
ListMapBench$ 13 1 1 1 0 1 1 2 2 2
-Dsize=120 -Dnreads=10000 ListMapBench 10
ListMapBench$ 16 8 4 3 3 2 2 1 1 3
-Dsize=120 -Dnreads=100000 ListMapBench 10
ListMapBench$ 30 18 16 16 14 14 18 16 14 13
-Dsize=120 -Dnreads=1000000 ListMapBench 10
ListMapBench$ 135 124 121 122 120 124 125 124 123 122
-Dsize=120 -Dnreads=1000000 ListMapBench 15
ListMapBench$ 136 122 123 124 123 124 125 125 125 122 124 121 124 123 122
-Dsize=120 -Dnreads=10000000 ListMapBench 15
ListMapBench$ 1205 1191 1199 1201 1199 1198 1208 1202 1199 1201 1202 1199 1199 1200 1213
-Dsize=120 -Dnreads=1000 ListMapBench 10
ListMapBench$ 14 3 2 1 1 1 1 1 0 1
-Dsize=120 -Dnreads=10000 ListMapBench 10
ListMapBench$ 16 8 6 1 3 3 3 3 3 2
-Dsize=120 -Dnreads=100000 ListMapBench 10
ListMapBench$ 30 17 14 16 22 20 16 19 17 14
-Dsize=120 -Dnreads=1000000 ListMapBench 10
ListMapBench$ 136 124 124 125 126 125 124 126 126 126
-Dsize=120 -Dnreads=1000000 ListMapBench 15
ListMapBench$ 136 123 124 121 121 125 124 125 124 125 125 124 123 123 124
-Dsize=120 -Dnreads=10000000 ListMapBench 15
ListMapBench$ 1196 1184 1216 1200 1201 1210 1197 1202 1206 1203 1199 1198 1201 1203 1199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment