I need to calculate the runtime of a code in scala. The code is.
val data = sc.textFile("/home/david/Desktop/Datos Entrada/household/household90Parseado.txt") val parsedData = data.map(s => Vectors.dense(s.split(' ').map(_.toDouble))).cache() val numClusters = 5 val numIterations = 10 val clusters = KMeans.train(parsedData, numClusters, numIterations)
I need to know the runtime to process this code, the time have to be on seconds.
Yes, Scala runtime runs on top of JVM and all it needs is supporting scala-lang. jar library and "a plain" JVM of appropriate version. Scala code is compiled to JVM bytecode.
Based on discussion here, you'll want to use System.nanoTime
to measure the elapsed time difference:
val t1 = System.nanoTime /* your code */ val duration = (System.nanoTime - t1) / 1e9d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With