Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lambda vs Manual Metafactory

Louis Denning
Ranch Hand
Posts: 64
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was toying around with creating lambdas using LambdaMetafactory, and I wondered if there was any speed difference between reflectively calling a method, calling a MethodHandle, a manually created lambda, and a regular old lambda. For simplicity, the function to be tested is a plain static void method with no parameters. I let the tests go for about 12000 dummy runs to hopefully warm up the JVM into compiling the bytecode before timing them, 10000 invocations at a time. Interestingly, most of the time, invoking the regular old lambda, and even the reflective Method, was a little faster than calling the lambda created using LambdaMetafactory and the MethodHandle. Why is this?

Also, I don't have the code on me right now, but I will put it here when I can.


  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic