Skip to content

Instantly share code, notes, and snippets.

@natemurthy
Last active August 29, 2015 14:02
Show Gist options
  • Save natemurthy/47149eff62bf8fe45bfa to your computer and use it in GitHub Desktop.
Save natemurthy/47149eff62bf8fe45bfa to your computer and use it in GitHub Desktop.
// map.scala
object `map` {
def main (args: Array[String]) {
val start = System.nanoTime
println("\n(Map) multiplying 60 million elements by 2")
val dbls = (1L to 60000000L).toArray.map(_*2)
println("(Reduce) sum: %d".format(dbls.sum))
val end = System.nanoTime
println("Total MapReduce time: %f".format((end-start)/1.0e9))
}
}
// breeze_map.scala
import breeze.linalg.DenseVector
object breeze_map {
def main(args: Array[String]): Unit = {
val start = System.nanoTime
println("\n(Map) multiplying 60 million elements by 2")
val dbls = DenseVector((1L to 60000000L).toArray) :* 2L
println("(Reduce) sum: %d".format(dbls.sum))
val end = System.nanoTime
println("Total MapReduce time: %f".format((end-start)/1.0e9))
}
}
// saddle_map.scala
import org.saddle.{Vec, Series}
object saddle_map {
def main(args: Array[String]): Unit = {
val start = System.nanoTime
println("\n(Map) multiplying 60 million elements by 2")
val dbls = Series(Vec((1L to 60000000L).toArray))*2L
println("(Reduce) sum: %d".format(dbls.sum))
val end = System.nanoTime
println("Total MapReduce time: %f".format((end-start)/1.0e9))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment