Many modern frameworks (Spring, Hibernate) provide very nice dynamic behaviors with use of Java dynamic proxies, but what's the exact performance cost associated with it? Are there public benchmarks available for Sun JVM?
Asked
Active
Viewed 1.7k times
3 Answers
44
A few pointers:
- Debunking myths: proxies impact performance (have a look at the comments too)
- Java theory and practice: Decorating with dynamic proxies
- Benchmarking the cost of dynamic proxies

Pascal Thivent
- 562,542
- 136
- 1,062
- 1,124
-
2Thanks for the links, especially for the last one that provides the real benchmark number: factor of 1.63 in raw use – Gennady Shumakher Dec 06 '09 at 19:44
8
I don't know if there is any performance analysis in the framework you mentioned, but in my project lambdaj I made a very large use of dynamic proxy using the same technology (cglib). In the pdf that explains how my library works you can also find an interesting performance comparison on this subject.

Mario Fusco
- 13,548
- 3
- 28
- 37
-
1If I got it right your framework slows the iterations by average factor of 4.56, but would you relate it to the cglib proxies or to other elements of the library? – Gennady Shumakher Dec 06 '09 at 20:07
-
The 2 things that mostly slow down the performance of lambdaj are cglib and reflection. My measurements shows that the second is just a bit more relevant than the first. So I suppose that roughly an invocation through cglib can be considered about twice slower than a normal one. – Mario Fusco Dec 06 '09 at 20:59
2
According to Remi Forax, java proxy forbid the Jit compiler to do correctly his job (inlining in this case).
See his rewrote of Proxy

Gab
- 7,869
- 4
- 37
- 68