progs/re3.scala
changeset 638 e951b9688bb2
parent 631 60608e227478
child 647 d74702cba346
equal deleted inserted replaced
637:936560fab865 638:e951b9688bb2
    86   (end - start)/(i * 1.0e9)
    86   (end - start)/(i * 1.0e9)
    87 }
    87 }
    88 
    88 
    89 
    89 
    90 //test: (a?{n}) (a{n})
    90 //test: (a?{n}) (a{n})
    91 for (i <- 0 to 7000 by 1000) {
    91 for (i <- 0 to 8000 by 1000) {
    92   println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
    92   println(f"$i: ${time_needed(3, matcher(EVIL1(i), "a" * i))}%.5f")
    93 }
    93 }
    94 
    94 
    95 //test: (a*)* b
    95 //test: (a*)* b
    96 for (i <- 0 to 6000000 by 500000) {
    96 for (i <- 0 to 6000000 by 500000) {
    97   println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
    97   println(f"$i: ${time_needed(3, matcher(EVIL2, "a" * i))}%.5f")
    98 }
    98 }
    99 
    99 
   100 
   100 
   101 // size of a regular expressions - for testing purposes 
   101 // size of a regular expressions - for testing purposes 
   102 def size(r: Rexp) : Int = r match {
   102 def size(r: Rexp) : Int = r match {