equal
  deleted
  inserted
  replaced
  
    
    
|      7  |      7  | 
|      8 public class catastrophic { |      8 public class catastrophic { | 
|      9     public static void main(String[] args) { |      9     public static void main(String[] args) { | 
|     10  |     10  | 
|     11         //we always run all the tests twice -> warmup of the JVM |     11         //we always run all the tests twice -> warmup of the JVM | 
|     12         for (int runs = 0; runs < 2; runs++) { |     12         for (int runs = 0; runs < 3; runs++) { | 
|     13              |     13              | 
|     14             Pattern pattern = Pattern.compile("(a*)*b"); |     14             Pattern pattern = Pattern.compile("(a*)*b"); | 
|     15              |     15              | 
|     16             // Run from 5 to 28 characters |     16             // Run from 5 to 28 characters | 
|     17             for (int length = 5; length < 28; length++) { |     17             for (int length = 70000; length < 70001; length++) { | 
|     18                  |     18                  | 
|     19                 // Build input of specified length |     19                 // Build input of specified length | 
|     20                 String input = ""; |     20                 String input = ""; | 
|     21                 for (int i = 0; i < length; i++) { input += "a"; } |     21                 for (int i = 0; i < length; i++) { input += "a"; } | 
|     22                  |     22                  | 
|     25                 for (int i = 0; i < 2; i++) { |     25                 for (int i = 0; i < 2; i++) { | 
|     26                     pattern.matcher(input).find(); |     26                     pattern.matcher(input).find(); | 
|     27                 } |     27                 } | 
|     28                  |     28                  | 
|     29                 System.out.println(length + " " + input + ": "  |     29                 System.out.println(length + " " + input + ": "  | 
|     30                        + ((System.nanoTime() - start) / 2000000000d)  |     30                        + ((System.nanoTime() - start) / 3000000000d)  | 
|     31                        + "s"); |     31                        + "s"); | 
|     32             } |     32             } | 
|     33         } |     33         } | 
|     34     } |     34     } | 
|     35 }  |     35 }  |