Created
November 23, 2009 17:37
-
-
Save stepancheg/241218 to your computer and use it in GitHub Desktop.
Arrays.sort
This file contains hidden or 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
def sort(a: Array[Int]) = { | |
java.util.Arrays.sort(a) | |
} | |
def profile[T](what: String)(action: => T) = { | |
val start = System.currentTimeMillis() | |
val r = action | |
val delta = System.currentTimeMillis() - start | |
println(what + ": " + delta + "; " + r) | |
} | |
while (true) { | |
val a = new Array[Int](20 * 1000 * 1000) | |
val r = new java.util.Random | |
for (i <- 1 to a.length) { | |
a(i - 1) = r.nextInt() | |
} | |
profile("sort")(sort(a)) | |
} | |
// vim: set ts=4 sw=4 et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment