uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marshall Schor <...@schor.com>
Subject Adventures with Java 8, benchmarking
Date Fri, 11 Sep 2015 21:56:23 GMT
This is more like a mini-blog post...

While experimenting with some new Java 8 features, I stumbled on some amazing

The first: Java 8 can call via an indirection through a variable, an aribtrary
method, essentially just as fast as if you coded a direct call.  So, for
instance, if you have a method "m", and called it like this:

you can also do something like:
  MyFunctionalInterface fi = ...  // code that returns a CallSite cast to a
functional interface, which has the method "m" inside it

and then call it

and it runs essentially just as fast as the direct call.

My first test of this was with my attempt at doing a mini-java-benchmark, trying
to be careful to avoid the JIT optimizing away everything...  With this, I
measured this result - this new approach is much faster than old-fashioned

Then, I climbed the learning curve on Java Microbenchmarking Harness (jmh). 
There's a great presentation on this here: https://vimeo.com/78900556
Using this I more accurately could determine the performance, and confirmed it
runs a bit slower than direct, but almost as fast.  To make the functional
interface that's fast, I'm using the LambaMetafactory.metafactory approach. 
other approaches, such as using MethodHandleProxies.asInterfaceInstance seem
(with current Java 8) to not perform well.

This discovery can enable designs which can include more reflection style
invocations, I think.


View raw message