MCPcopy Index your code
hub / github.com/bazelbuild/bazel / main

Method main

src/test/java/net/starlark/java/eval/Benchmarks.java:83–239  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

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");

Callers

nothing calls this directly

Calls 15

failMethod · 0.95
readFileMethod · 0.95
withPredeclaredMethod · 0.95
createMethod · 0.95
createTransientMethod · 0.95
execFileMethod · 0.95
getGlobalsMethod · 0.95
runMethod · 0.95
formatDurationMethod · 0.95
formatBytesMethod · 0.95
startsWithMethod · 0.80
endsWithMethod · 0.80

Tested by

no test coverage detected