progs/matcher/re3.sc
changeset 742 b5b5583a3a08
parent 725 f345e89895f5
child 769 f9686b22db7e
equal deleted inserted replaced
741:e66bd5c563eb 742:b5b5583a3a08
    94   val end = System.nanoTime()
    94   val end = System.nanoTime()
    95   (end - start)/(i * 1.0e9)
    95   (end - start)/(i * 1.0e9)
    96 }
    96 }
    97 
    97 
    98 
    98 
    99 //test: (a?{n}) (a{n})
    99 //
   100 @doc("Test (a?{n}) (a{n})")
   100 @doc("Test (a?{n}) (a{n})")
   101 @main
   101 @main
   102 def test1() = {
   102 def test1() = {
       
   103   println("Test (a?{n}) (a{n})")
       
   104 
   103   for (i <- 0 to 8000 by 1000) {
   105   for (i <- 0 to 8000 by 1000) {
   104     println(f"$i: ${time_needed(3, matcher(EVIL1(i), "a" * i))}%.5f")
   106     println(f"$i: ${time_needed(3, matcher(EVIL1(i), "a" * i))}%.5f")
   105   }
   107   }
   106 }  
   108 }  
   107 
   109 
   108 //test: (a*)* b
   110 //
   109 @doc("Test (a*)* b")
   111 @doc("Test (a*)* b")
   110 @main
   112 @main
   111 def test2() = {
   113 def test2() = {
       
   114   println("Test (a*)* b")
       
   115 
   112   for (i <- 0 to 6000000 by 500000) {
   116   for (i <- 0 to 6000000 by 500000) {
   113     println(f"$i: ${time_needed(3, matcher(EVIL2, "a" * i))}%.5f")
   117     println(f"$i: ${time_needed(3, matcher(EVIL2, "a" * i))}%.5f")
   114   }
   118   }
   115 }
   119 }
   116 
   120