(String[] args)
| 81 | private static boolean ok = true; |
| 82 | |
| 83 | public static void main(String[] args) throws Exception { |
| 84 | Pattern filter = null; // default: all |
| 85 | long budgetNanos = -1; |
| 86 | int iterations = -1; |
| 87 | |
| 88 | // parse flags |
| 89 | int i; |
| 90 | for (i = 0; i < args.length; i++) { |
| 91 | if (args[i].equals("--")) { |
| 92 | i++; |
| 93 | break; |
| 94 | |
| 95 | } else if (args[i].equals("--help")) { |
| 96 | System.out.println(HELP); |
| 97 | System.exit(0); |
| 98 | |
| 99 | } else if (args[i].equals("--filter")) { |
| 100 | if (++i == args.length) { |
| 101 | fail("--filter needs an argument"); |
| 102 | } |
| 103 | try { |
| 104 | filter = Pattern.compile(args[i]); |
| 105 | } catch (PatternSyntaxException ex) { |
| 106 | fail("for --filter, invalid regexp: %s", ex.getMessage()); |
| 107 | } |
| 108 | |
| 109 | } else if (args[i].equals("--seconds")) { |
| 110 | if (++i == args.length) { |
| 111 | fail("--seconds needs an argument"); |
| 112 | } |
| 113 | try { |
| 114 | budgetNanos = (long) (1e9 * Double.parseDouble(args[i])); |
| 115 | } catch (NumberFormatException unused) { |
| 116 | fail("for --seconds, got '%s', want floating-point number of seconds", args[i]); |
| 117 | } |
| 118 | if (!(0 <= budgetNanos && budgetNanos <= 1e13)) { |
| 119 | fail("--seconds out of range"); |
| 120 | } |
| 121 | |
| 122 | } else if (args[i].equals("--iterations")) { |
| 123 | if (++i == args.length) { |
| 124 | fail("--iterations needs an integer argument"); |
| 125 | } |
| 126 | try { |
| 127 | iterations = Integer.parseInt(args[i]); |
| 128 | } catch (NumberFormatException e) { |
| 129 | fail("for --iterations, got '%s', want an integer number of iterations", args[i]); |
| 130 | } |
| 131 | if (iterations < 0) { |
| 132 | fail("--iterations out of range"); |
| 133 | } |
| 134 | |
| 135 | } else { |
| 136 | fail("unknown flag: %s", args[i]); |
| 137 | } |
| 138 | } |
| 139 | if (i < args.length) { |
| 140 | fail("unexpected arguments"); |
nothing calls this directly
no test coverage detected