order of operation expense?

In interest of optimization, ho do Java operations ( int division, float division, new, etc.) compare to each other in terms of processing expense.

Also, what about opengl functions?
I am especially interested in useshader() vs bindtexture() vs bindbuffer() and attribute location functions.

I would expect that to probably be implementation-dependent.

But of course, the best way to test this is with a benchmark. I’d be really curious to see what you find though.

Micro benchmarks are bad. In this case they are truly awful. At least the decent JVM’s (open jdk and sun jdk) do many optimizations. So that muladd or addmul instructions etc are used where possible (for example). I belive 7 or 8 even includes some SSE stuff etc. They also will do many of the peep hole optimizations (ie use a shift instead of a * by a power of 2 for example).

On modern hardware moving the data around is typically as expensive as multiplies and adds. Cache performance is typically what matters.

TL;DR Write the game/program. Then profile. It really is the only way to tell on modern CPU architectures.

how about various opengl bind or shader calls?

Those are just trivial calls to drivers; the Java bit is a matter of nanoseconds.

Cas :slight_smile: