Class FastCursorRandomAccessLoops
java.lang.Object
net.imglib2.loops.FastCursorRandomAccessLoops
This class aims to avoid performance problems of the Java just in time compilation when
running a loop that executes an action on a
Cursor and multiple RandomAccesses.
Such a loop might look like this:
while(--n >= 0) {
A a = cursorA.next();
randomAccessB.setPosition( cursorA );
randomAccessC.setPosition( cursorA );
action.accept( a, randomAccessB.get(), randomAccessC.get() );
}
Usually such a loop has significant performance problems when used together multiple different classes
that implement Cursor, RandomAccess, and action interfaces. This is caused by the JIT-compiler
who simple performs badly in these situations.
This class solves these performance problems by holding multiple copies of the bytecode of these loops.
A bytecode copy can be individually optimized by the Java JIT compiler to perform optimally for a
specific use case.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static LongConsumercreateLoop(Object action, Cursor<?> cursor, List<? extends RandomAccess<?>> randomAccesses) (package private) static voidloop(Object action, long n, Cursor<?> cursor, List<? extends RandomAccess<?>> randomAccesses)
-
Field Details
-
factories
-
-
Constructor Details
-
FastCursorRandomAccessLoops
private FastCursorRandomAccessLoops()
-
-
Method Details
-
loop
static void loop(Object action, long n, Cursor<?> cursor, List<? extends RandomAccess<?>> randomAccesses) -
createLoop
private static LongConsumer createLoop(Object action, Cursor<?> cursor, List<? extends RandomAccess<?>> randomAccesses)
-