progs/matcher/re2.sc
changeset 742 b5b5583a3a08
parent 725 f345e89895f5
child 767 bdd12391d345
equal deleted inserted replaced
741:e66bd5c563eb 742:b5b5583a3a08
    72   (end - start) / (i * 1.0e9)
    72   (end - start) / (i * 1.0e9)
    73 }
    73 }
    74 
    74 
    75 
    75 
    76 
    76 
    77 // test: (a?{n}) (a{n})
       
    78 @doc("Test (a?{n}) (a{n})")
    77 @doc("Test (a?{n}) (a{n})")
    79 @main
    78 @main
    80 def test1() = {
    79 def test1() = {
       
    80   println("Test (a?{n}) (a{n})")
       
    81 
    81   for (i <- 0 to 1000 by 100) {
    82   for (i <- 0 to 1000 by 100) {
    82     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
    83     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
    83   }
    84   }
    84 }  
    85 }  
    85 
    86 
    86 // test: (a*)* b
    87 
    87 @doc("Test (a*)* b")
    88 @doc("Test (a*)* b")
    88 @main
    89 @main
    89 def test2() = {
    90 def test2() = {
    90   for (i <- 0 to 20) {
    91   println("Test (a*)* b")
       
    92 
       
    93   for (i <- 0 to 20 by 2) {
    91     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
    94     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
    92   }
    95   }
    93 }
    96 }
    94 
    97 
    95 // the size of a regular expressions - for testing purposes 
    98 // the size of a regular expressions - for testing purposes