Guest User

Untitled

a guest
Feb 18th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import static groovyx.gpars.GParsPool.*
  2.  
  3. def m1 = { num ->
  4. def st = System.currentTimeMillis()
  5. withPool(3) {
  6. println(
  7. (0..num).parallel
  8. .filter{println "in fil m1 [$it]"; it < 5}
  9. .map {println "in map m1 [$it]"; it * 2 }
  10. .collection
  11. )
  12. }
  13. def ed = System.currentTimeMillis()
  14. ed - st
  15. }
  16. def m2 = { num ->
  17. def st = System.currentTimeMillis()
  18. // withPool {
  19. println(
  20. (0..num)
  21. .findAll{println "in findAll m2 [$it]"; it < 5 }
  22. .collect{println "in collect m2 [$it]"; it * 2 }
  23. )
  24. // }
  25. def ed = System.currentTimeMillis()
  26. ed - st
  27. }
  28.  
  29. print m1(100)
  30. print ', '
  31. println m2(100)
Add Comment
Please, Sign In to add comment