Hi,
sadly, avoiding getSimpleBinaryName is where most of the gain comes
from, avoiding
getSimpleName only improves marginally on the baseline:
Benchmark Mode Cnt Score Error Units
Clazz.isAnonymousClass_Anon avgt 10 192.522 ± 33.214 ns/op
Clazz.isAnonymousClass_Regular avgt 10 115.770 ± 19.953 ns/op
Wrapping the checkPermission call inside getEnclosingMethod so that
Reflection.getCallerClass() doesn't happening improves things a bit, but
still
not close:
Clazz.isAnonymousClass_Anon avgt 10 187.074 ± 38.128 ns/op
Clazz.isAnonymousClass_Regular avgt 10 96.196 ± 15.709 ns/op
/Claes
On 2016-12-01 17:57, Mandy Chung wrote:
Hi Claes,
What is the performance difference if this method calls getSimpleBinaryName?
Your patch exposes the implementation details and sensitive to the change
there, if any.
Mandy
On Dec 1, 2016, at 5:38 AM, Claes Redestad <claes.redes...@oracle.com> wrote:
Hi,
due to recent interest to optimize Class.isAnonymousClass[1] I took
a look at the implementation and found that we can further improve
performance of this method, especially when asking non-anonymous
classes[2].
As such calls are a common occurrence during startup and bootstrap
of lambdas this actually appears rather worthwhile:
Webrev: http://cr.openjdk.java.net/~redestad/8170595/webrev.01/
Bug: https://bugs.openjdk.java.net/browse/JDK-8170595
Thanks!
/Claes
[1]
http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-December/045116.html
[2]
Benchmark Mode Cnt Score Error Units
Clazz.isAnonymousClass_Anon avgt 50 200.900 ± 15.503 ns/op
Clazz.isAnonymousClass_Regular avgt 50 136.896 ± 9.605 ns/op
Clazz.isAnonymousClass_Anon avgt 50 186.564 ± 12.219 ns/op
Clazz.isAnonymousClass_Regular avgt 50 33.878 ± 1.524 ns/op
See bug for benchmark source