In my previous blog post I mentioned that with JCols I explored evaluating user specified JavaScript expressions in Java with Rhino. In order to make JCols as fast as possible I recently experimented with evaluating user specified Java expressions that are compiled using Java 6's JavaCompiler (that's just the name of the interface, but that's what I'll refer to it as). I've concluded the following about the JavaCompiler:
My next concern was splitting each line into an array of strings. I found that String.split("\\s+") was slower than using a precompiled expression. But I also found that either technique is slower than custom code that does the splitting by stepping through the line a character at a time.
There are probably additional performance gains to be made, but JCols is close to GNU AWK in performance now. GNU AWK is surprising hard to beat considering that the interpreter does not support JIT compilation.