byte[] bytes = getContents(args);
int iterations = getIterations(args);
int[] parsers = getParsers(args);
System.out.println("Parsing " + args[0] + " " + iterations + " times");
DefaultRubyParser parser = new DefaultRubyParser();
parser.setWarnings(new NullWarnings(null));
Ruby runtime = Ruby.getGlobalRuntime();
RubyInstanceConfig rconfig = new RubyInstanceConfig();
ParserConfiguration config = new ParserConfiguration(runtime, 0, false, false, true, rconfig);
for (int x = 0; x < parsers.length; x++) {
System.out.println("Benching parse with " + (parsers[x] == 0 ? "InputStream" : "ByteArray") + "LexerSource");
long start = System.nanoTime();
for (int i = 0; i < iterations; i++) {
parser.parse(config, getLexerSource(args[0], bytes, config, parsers[x] == 0));
}
System.out.println("Parse took: " + ((System.nanoTime() - start) * 1.0 / 1000000.0) + "ms");
}
} catch (Exception e) {
System.err.println("Parse bench failed: " + e.getMessage());