On Thursday, September 4, 2003, at 02:01 AM, Sergei Batiuk wrote:
That is not true. A normal Java method invocation on an Object reference (not an interface reference) takes about 3 nanoseconds on my 1g mac. A Java reflection invocation takes about 350 nanoseconds == 0.000 350 ms. My guess is you thing that is slow (and so do I). Instead of using Java reflection we will be using proxies generated by cglib which supports reflective style calls using a MethodProxy object. A reflection invocation using MethodProxy on my 1g mac takes 7 nanoseconds.
I have some issues with your timings there. Are you using the client HotSpot? I get for invocation only around 40 cycles with -server and 440 with -client. For lookup and invocation I get 3,200 with -server and 13,500 -client. Timings on a PII/266 running Linux and Sun JRE 1.4.2, and obviously take microbenchmarks with a pinch of salt. Loops with conventional virtual method invocations can be completely optimised away.
Something to be wary of is start up times. IIRC, (server) HotSpot (and I assume equivalent in other modern JREs) compile proxies for Method. Obviously they don't necessarily have to go through byte code, so start up times may be significantly faster.
I'm not saying cglib decisions are wrong, just making sure they're made with appropriate information...
Tom Hawtin
