Skip to content

Instantly share code, notes, and snippets.

@okram
Created November 4, 2012 19:22
Show Gist options
  • Save okram/4013182 to your computer and use it in GitHub Desktop.
Save okram/4013182 to your computer and use it in GitHub Desktop.
public void testStartupCostsEngineVsCompiled() throws Exception {
final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
Bindings bindings = engine.createBindings();
bindings.put("g", TinkerGraphFactory.createTinkerGraph());
int runs = 500;
long totalTime = 0l;
for (int i = 0; i < runs; i++) {
long time = System.currentTimeMillis();
CompiledScript script = engine.compile("g.v(1).out.count()");
script.eval(bindings);
totalTime += System.currentTimeMillis() - time;
}
System.out.println(totalTime);
totalTime = 0l;
for (int i = 0; i < runs; i++) {
long time = System.currentTimeMillis();
engine.eval("g.v(1).out.count()",bindings);
totalTime += System.currentTimeMillis() - time;
}
System.out.println(totalTime);
}
///////
484
8258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment