Matt Pierce wrote:
> I find that even once I have evaluated both the tools script
> and the primary script using the Interpreter eval method previously,
> the same primary script on the same interpreter takes 900 msec to do
> something I can do in under 100 msec in java.
Of course. BeanShell doesn't dynamically translate scripts into bytecode or
anything like that - it's still a pure interpreter, so the 9-to-1 is still
excellent, given the technology.
The only way to speed this up would be for BeanShell to generate byte code
and load that - I don't know what the plans are for such functionality.
> What is the fastest way that I can run a script (considering that
> I have time I don't care about losing on startup to "load" it in advance)?
How dynamic are these scripts? Are some executed more often than others?
It may help to code some of these in as pure a dialect of Java as you can,
and once the script is "finished" in terms of evolution, wrap it up as a
Java class, compile it into a jar, and load the class from there and execute
This is what I ended up doing - I have an execution interface that can take
either a BeanShell script (that I wrap in a dummy method with a known
interface), or a Java class that implements a certain interface, and execute
The off-the-cuff scripts, and the ones that are not very CPU-intensive or
not executed very often, stay as BeanShell scripts. The ones that are
performance-critical get compiled and loaded that way.