progs/matcher/re1.sc
changeset 961 c0600f8b6427
parent 941 66adcae6c762
child 965 94f5cce73a4f
equal deleted inserted replaced
960:c7009356ddd8 961:c0600f8b6427
    98   (end - start) / (i * 1.0e9)
    98   (end - start) / (i * 1.0e9)
    99 }
    99 }
   100 
   100 
   101 
   101 
   102 // test: (a?{n}) (a{n})
   102 // test: (a?{n}) (a{n})
   103 @arg(doc = "Test (a?{n}) (a{n})")
       
   104 @main
       
   105 def test1() = {
   103 def test1() = {
   106   println("Test (a?{n}) (a{n})")
   104   println("Test (a?{n}) (a{n})")
   107 
   105 
   108   for (i <- 0 to 20 by 2) {
   106   for (i <- 0 to 20 by 2) {
   109     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
   107     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
   110   }
   108   }
   111 }
   109 }
   112 
   110 
   113 // test: (a*)* b
   111 // test: (a*)* b
   114 @arg(doc = "Test (a*)* b")
       
   115 @main
       
   116 def test2() = {
   112 def test2() = {
   117   println("Test (a*)* b")
   113   println("Test (a*)* b")
   118 
   114 
   119   for (i <- 0 to 20 by 2) {
   115   for (i <- 0 to 20 by 2) {
   120     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
   116     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
   163 size(ders("aaaaaaaaaaaa".toList, BIG))  // 536
   159 size(ders("aaaaaaaaaaaa".toList, BIG))  // 536
   164 
   160 
   165 
   161 
   166 size(ders(("a" * 30).toList, BIG))      // 31010539
   162 size(ders(("a" * 30).toList, BIG))      // 31010539
   167 
   163 
   168 @main
   164 
   169 def test3() = {
   165 def test3() = {
   170   println("Test (a + aa)*")
   166   println("Test (a + aa)*")
   171 
   167 
   172   for (i <- 0 to 30 by 5) {
   168   for (i <- 0 to 30 by 5) {
   173     println(f"$i: ${time_needed(2, matcher(BIG, "a" * i))}%.5f")
   169     println(f"$i: ${time_needed(2, matcher(BIG, "a" * i))}%.5f")
   174   }
   170   }
   175 }
   171 }
   176 
   172 
   177 
       
   178 @arg(doc = "All tests.")
       
   179 @main
   173 @main
   180 def all() = { test1(); test2() ; test3() } 
   174 def all() = { test1(); test2() ; test3() } 
       
   175 
       
   176 //all()