Guest User

Untitled

a guest
Oct 16th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.53 KB | None | 0 0
  1.   def testCaseClassCost() {
  2.     var loops = 0
  3.     val foo : List[Int] = List(1,3,5,7)
  4.     def funk(f : List[Int]) {loops += 1}
  5.  
  6.     var startTime = System.nanoTime
  7.     while(loops < 1000000) {
  8.       funk(List(1,3,5,7))
  9.     }
  10.     var delta = System.nanoTime - startTime
  11.     println("Time with JIT list: " + (delta/1000000L))
  12.  
  13.     loops = 0
  14.     startTime = System.nanoTime
  15.     while(loops < 1000000) {
  16.       funk(foo)
  17.     }
  18.     delta = System.nanoTime - startTime
  19.     println("Time with prebuilt list: " + (delta/1000000L))
  20.   }
Add Comment
Please, Sign In to add comment