RSS RSS feed | Atom Atom feed
Popular Articles: Tom Riddle's Magical Diary | AJAX Lego Robot | AJAX CAPTCHA | SQL Multisets

Groovy vs BeanShell

Quick speed performance test

Below is a quick and dirty test to compare the speed performance between bean shell and groovy. Bean shell is an order of magnitude faster. If you don't need groovy closure and other nice groovy features...just use bean shell. It's only one small jar away.
public static void main(String[] args) throws EvalError { StringBuilder script = new StringBuilder(); for (int i=0;i<900;i++) { script.append("res"); script.append(i); script.append("="); script.append(i+"+"+i+"*"+i); script.append(";\n"); } GroovyShell groovyShell = new GroovyShell(); Interpreter bsh = new Interpreter(); long t = System.currentTimeMillis(); groovyShell.evaluate(script.toString()); System.out.println(System.currentTimeMillis() - t); t = System.currentTimeMillis(); for (int i=0;i<1000;i++) { int j = i+i*i; } System.out.println(System.currentTimeMillis() - t); t = System.currentTimeMillis(); bsh.eval(script.toString()); System.out.println(System.currentTimeMillis() - t); }
slashdot digg del.icio.us technorati [more]