com.phasmidsoftware.number.misc.Benchmark.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of number_2.13 Show documentation
Show all versions of number_2.13 Show documentation
Fuzzy, Lazy Scala library for numerical computation
The newest version!
package com.phasmidsoftware.number.misc
object Benchmark {
implicit class Repetitions(n: Int) {
def times[R](x: => R): (R, Double) = {
val start = System.nanoTime()
for (_ <- 1 to n) x
val r = x
val stop = System.nanoTime()
(r, 1E-6 * (stop - start) / n)
}
}
}