Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static groovyx.gpars.GParsPool.*
- def m1 = { num ->
- def st = System.currentTimeMillis()
- withPool(3) {
- println(
- (0..num).parallel
- .filter{println "in fil m1 [$it]"; it < 5}
- .map {println "in map m1 [$it]"; it * 2 }
- .collection
- )
- }
- def ed = System.currentTimeMillis()
- ed - st
- }
- def m2 = { num ->
- def st = System.currentTimeMillis()
- // withPool {
- println(
- (0..num)
- .findAll{println "in findAll m2 [$it]"; it < 5 }
- .collect{println "in collect m2 [$it]"; it * 2 }
- )
- // }
- def ed = System.currentTimeMillis()
- ed - st
- }
- print m1(100)
- print ', '
- println m2(100)
Add Comment
Please, Sign In to add comment