<div dir="ltr"><br><div class="gmail_extra">2013/6/24 Tobias Pietzsch <span dir="ltr"><<a href="mailto:pietzsch@mpi-cbg.de" target="_blank">pietzsch@mpi-cbg.de</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br></div><div><br></div><div>First regarding the slow (feel free to skip to this paragraph...). I played with unsigned short to ARGB conversion and noticed that it divides by scale factor for every pixel.</div>
<div>I thought that maybe we could speed it up a little by replacing that with a multiplication. Amazingly even in a language as Java that is seemingly far removed from the CPU this actually matters.</div></div></blockquote>
<div><br></div><div><br></div><div><br></div><div>Just wanted to point out that this particular surprise with division, in Java, I've run into before. Another aspect of it: for whatever reason the compiler or JIT are unable to map divisions by powers of two to a bit shift. For example:</div>
<div><br></div><div>int d = 16;</div><div>int a = 4096 / d;</div><div><br></div><div>... is about substantially slower (15 to 50%) than:</div><div><br></div><div>int s = 4;</div><div>int a = 4096 >> s;</div><div><br>
</div><div>... to the same result.</div><div><br></div><div>Albert </div><div><br></div><div><br></div><div> </div></div><a href="http://albert.rierol.net" target="_blank">http://albert.rierol.net</a><br><a href="http://www.ini.uzh.ch/~acardona/" target="_blank">http://www.ini.uzh.ch/~acardona/</a>
</div></div>