Attic/re-internal.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 21 Oct 2020 14:55:20 +0100
changeset 786 da2488db453e
parent 742 b5b5583a3a08
permissions -rw-r--r--
updated


// measures the time a function needs
def time_needed[T](i: Int, code: => T) = {
  val start = System.nanoTime()
  for (j <- 1 to i) code
  val end = System.nanoTime()
  (end - start)/(i * 1.0e9)
}
 

for (i <- 1 to 10001 by 300) {
  val re = ("((a?){" + i + "})(a{" + i + "})")
  println(i + " " + "%.5f".format(time_needed(1, ("a" * i).matches(re))))  
}