All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.phasmidsoftware.number.misc.Benchmark.scala Maven / Gradle / Ivy

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)
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy