diff -r b7221df9662a -r 065ca01b62ae progs/re2.scala --- a/progs/re2.scala Mon Aug 22 09:14:22 2016 +0200 +++ b/progs/re2.scala Mon Aug 22 23:05:43 2016 +0200 @@ -41,7 +41,8 @@ //optional: one or zero times def OPT(r: Rexp) = ALT(r, EMPTY) -def EVIL(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n)) +def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n)) +val EVIL2 = SEQ(STAR(CHAR('a')), CHAR('b')) def time_needed[T](i: Int, code: => T) = { val start = System.nanoTime() @@ -51,12 +52,17 @@ } //for (i <- 1 to 100) { -// println(i + ": " + "%.5f".format(time_needed(1, matches(EVIL(i), "a" * i)))) +// println(i + ": " + "%.5f".format(time_needed(1, matches(EVIL1(i), "a" * i)))) //} //a bit bolder test for (i <- 1 to 1000 by 50) { - println(i + " " + "%.5f".format(time_needed(1, matches(EVIL(i), "a" * i)))) + println(i + " " + "%.5f".format(time_needed(1, matches(EVIL1(i), "a" * i)))) } +for (i <- 1 to 4002 by 500) { + println(i + " " + "%.5f".format(time_needed(4, matches(EVIL2, "a" * i)))) +} + +