progs/re-internal.scala
author Christian Urban <urbanc@in.tum.de>
Sun, 22 Mar 2020 14:21:33 +0000
changeset 715 06e56c2ce349
parent 93 4794759139ea
permissions -rw-r--r--
started dotty files


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