progs/re2.scala
changeset 414 065ca01b62ae
parent 343 539b2e88f5b9
child 415 4ae59fd3b174
--- 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))))
+}
+
+