Upcoming version allows for a localvariable to be used as a view-controller, using the @MappedView
annotation:
public static void testLocalView(MappedFloat m, @MappedView int i)
{
for (i= 0; i< 5; i++)
{
m.value = (float) Math.random();
m.value *= 2.0f;
}
for (i= 0; i< 5; i++)
{
System.out.println("[" + i + "] =>" + m.value);
}
}
As you can see, the view of the mapped object is directly controlled by modifying the variable ‘i’ (in this case).
The variable ‘i’ is actually not transformed, which means that ‘i++’ is as fast as usual. The new behaviour is implemented by transforming the field-access to a pointer calculated with the value ‘i’ instead of ‘mapped.view’.
The localView code is ~3.2x as fast, according to Spasi’s new benchmarks (a bit faster than float[] access).
The mapped.view code is ~1.5x as fast, according to Spasi’s new benchmarks (half the speed of float[] access).
Please keep in mind that I am still working on further optimisations and that Spasi’s benchmarks are naturally not representing expected performance for the general case (there is no general case).
v0.10 (which we will now deem slow-ish) was already a huge performance boost, in real-world situations.
Barely tested v0.12 (beware of crashes)
Thanks to Spasi for benchmarking and analyzing the generated bytecode for bottlenecks.