DataBuffer, ColorModels and SampleModels
Alexey Ushakov
Alexey.Ushakov at Sun.COM
Mon May 14 22:09:35 UTC 2007
Hello Roman,
You are right concerning JNI overhead that we have when using native
library for per-pixel conversion. But actually it's not a case for most
user applications working with color conversion stuff. The most common
usage is color conversion for the whole image. In this case for most
common formats of the images (like sRGB, USHORT_GRAY, BYTE_GRAY)
conversion is performed for whole image at once. So, JNI overhead is not
sufficient here.
Could you please try out image test (attached) with your builds, so we
can figure out what's happening in most usual case.
Best Regards,
Alexey
Roman Kennke wrote On 14.05.2007 01:07,:
>Hi there,
>
>
>
>> that's pretty impressive!
>>
>>
>
>Yeah, and the performance is even more impressive. I've done a small
>test which converts 1000000 pixels from GRAY to sRGB. This is the
>performance with the plain OpenJDK (littlecms I suppose? Or even the old
>Kodak code.):
>
>roman at moonlight:~/src/test$
>~/src/openjdk/control/build/linux-i586/bin/java ColorTest
>converion time for 1000000 pixels: 13050
>
>
>roman at moonlight:~/src/test$
>~/src/openjdk/control/build/linux-i586/bin/java ColorTest
>converion time for 1000000 pixels: 406
>
>
>Find the test attached (It's derived from the gray->srgb testcase that I
>found in on of the bugreports). I know it's very simplistic and such,
>but it gives a clue about the performance difference. I suppose it's the
>100% Java approach that makes the difference here. Calling some JNI
>function 1000000 times is much worse than doing all this in Java I
>suppose.
>
>I would really like to run (or have one of you run) this against a
>conformance testsuite and see how it performs there.
>
>AFAIK, Sun and the FSF are talking about how to make code flowing
>between GNU Classpath and OpenJDK easy/easier.
>
>/Roman
>
>
>
>------------------------------------------------------------------------
>
>import java.awt.color.ColorSpace;
>
>public class ColorTest {
> private static final int NUM_COLS = 1000000;
>
> public static void main(String [] args) {
> // Fill pixel array with random data.
> int [] cols = new int[NUM_COLS];
> int [] outcols = new int[NUM_COLS * 3];
> for (int i = 0; i < NUM_COLS; i++) {
> cols[i] = (int) (Math.random() * 256);
> }
>
> ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
> float [] p = new float[1];
> int outIndex = 0;
> long start = System.currentTimeMillis();
> for (int i = 0; i < cols.length; i++) {
> p[0] = cols[i]/255.0f;
> float [] r = cs.toRGB(p);
> for (int j = 0; j < r.length; j++) {
> outcols[outIndex++] = (int)(r[j]*255);
> }
> }
> System.err.println("conversion time for " + NUM_COLS + " pixels: " + (System.currentTimeMillis() - start));
> }
>}
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20070515/6014f8c1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImageTest.java
Type: text/x-java
Size: 792 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20070515/6014f8c1/ImageTest.java>
More information about the 2d-dev
mailing list