Skip to content

Instantly share code, notes, and snippets.

@mocyuto
Created September 10, 2014 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mocyuto/b213883858185b3517a9 to your computer and use it in GitHub Desktop.
Save mocyuto/b213883858185b3517a9 to your computer and use it in GitHub Desktop.
use blitz
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