progs/matcher/re4.sc
changeset 871 94b84d880c2b
parent 826 b0352633bf48
equal deleted inserted replaced
870:739039774cee 871:94b84d880c2b
   104   val end = System.nanoTime()
   104   val end = System.nanoTime()
   105   (end - start) / (i * 1.0e9)
   105   (end - start) / (i * 1.0e9)
   106 }
   106 }
   107 
   107 
   108 
   108 
   109 @arg(doc = "Test (a?{n}) (a{n})")
   109 //@arg(doc = "Test (a?{n}) (a{n})")
   110 @main
   110 @main
   111 def test1() = {
   111 def test1() = {
   112   for (i <- 0 to 11000 by 1000) {
   112   for (i <- 0 to 11000 by 1000) {
   113     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
   113     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
   114   }
   114   }
   115 }
   115 }
   116 
   116 
   117 @arg(doc = "Test (a*)* b")
   117 //@arg(doc = "Test (a*)* b")
   118 @main
   118 @main
   119 def test2() = {
   119 def test2() = {
   120   for (i <- 0 to 7000000 by 500000) {
   120   for (i <- 0 to 7000000 by 500000) {
   121     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
   121     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
   122   }
   122   }
   123 } 
   123 } 
   124 
   124 
   125 @arg(doc = "All tests.")
   125 //@arg(doc = "All tests.")
   126 @main
   126 @main
   127 def all() = { test1(); test2() } 
   127 def all() = { test1(); test2() } 
   128 
   128 
   129 
   129 
   130 
   130