Guest User

Untitled

a guest
Apr 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. def sort(a: Array[Int]) = {
  2. java.util.Arrays.sort(a)
  3. }
  4.  
  5. def profile[T](what: String)(action: => T) = {
  6. val start = System.currentTimeMillis()
  7. val r = action
  8. val delta = System.currentTimeMillis() - start
  9. println(what + ": " + delta + "; " + r)
  10. }
  11.  
  12.  
  13. while (true) {
  14. val a = new Array[Int](20 * 1000 * 1000)
  15. val r = new java.util.Random
  16. for (i <- 1 to a.length) {
  17. a(i - 1) = r.nextInt()
  18. }
  19. profile("sort")(sort(a))
  20. }
  21.  
  22. // vim: set ts=4 sw=4 et:
Add Comment
Please, Sign In to add comment