#20 Slowness in BeanShell


for ( ; ii < 10000; ii++)
print ("after the loop:" + ii);
This is quite a bit slower in BeanShell than in other programs.
Looking at the source code, I suspect that the problem is not
in the loop but in variable handling. Specifically the follwing:
private Object consumeNextObjectField( Interpreter interpreter )
throws EvalError
Is it a class name?
If we're just starting eval of name (and it wasn't a variable
reference per above) try to make it, else fail.
Class names are attempted before long variable chains because
we don't have any way to "back out" if we start down a chain
and we're wrong. In general this seems ok.
So each time ii is looked at BeanShell checks to see if it's a class or
a variable, and that takes time.


  • Pat Niemeyer

    Pat Niemeyer - 2001-05-09

    Logged In: YES

    The time to execute a large empty loop as in the above has
    been cut in half in release 1.1alpha7.

    There will likely be additional significant performance
    improvements possible if we start caching more structural
    information... Right now, as bsh is evolving we have not
    focused on performance as much as correctness and feature

  • Pat Niemeyer

    Pat Niemeyer - 2001-05-09
    • priority: 5 --> 2

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks