Created
September 10, 2014 15:37
-
-
Save mocyuto/b213883858185b3517a9 to your computer and use it in GitHub Desktop.
use blitz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.par._ | |
import scala.collection.par.Scheduler.Implicits.global | |
object iterate { | |
def triangles_blitz(n: Int) = for { | |
x <- (0 until n).toPar | |
y <- 0 until x | |
} yield { y }: @unchecked | |
def triangles(n: Int) = for { | |
x <- (0 until n) | |
y <- 0 until x | |
} yield y | |
def main(args: Array[String]): Unit = { | |
val start = System.currentTimeMillis | |
triangles(10000) | |
println((System.currentTimeMillis - start) + "msec") | |
val start2 = System.currentTimeMillis | |
triangles_blitz(10000) | |
println((System.currentTimeMillis - start2) + "msec") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment