Advertisement
Guest User

Untitled

a guest
Aug 21st, 2015
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. // Benchmark is a trait that has been removed from recent Scala versions, but was very handy...
  2.  
  3. object ListConcatTest extends testingRJ.Benchmark {
  4.  
  5. val longList = (1 to 100).toList
  6. val medList = (1 to 30).toList
  7. val shortList = (1 to 3).toList
  8. var result: List[Int] = _
  9.  
  10. def run(): Unit = {
  11. // times are in ms for the last of 5 100k trials
  12.  
  13. //result = longList ::: shortList // 261
  14. //result = longList ++ shortList // 261
  15.  
  16. //result = medList ::: medList ::: medList //156
  17. //result = medList ++ medList ++ medList //242
  18.  
  19. //result = medList ::: medList // 78
  20. //result = medList ++ medList // 80
  21.  
  22. //result = shortList ::: shortList ::: longList // 18
  23. //result = shortList ++ shortList ++ longList // 32
  24.  
  25. //result = longList ::: shortList ::: shortList // 284
  26. //result = longList ++ shortList ++ shortList // 553
  27. //result = List(longList, shortList, shortList).flatten // 121
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement