DataBuffer, ColorModels and SampleModels

Jeannette Hung Jeannette.Hung at Sun.COM
Mon May 14 05:15:49 UTC 2007


Wow...  That's a huge difference.  Did you compare the pixel values 
between your build, the openjdk build, and the production JRE build?  I 
know the color code isn't straightforward for conversion between a gray 
and a sRGB color space since I think the gray space is linear and the 
sRGB one is not.

Thanks
jeannette

Roman Kennke wrote:
> 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));
>     }
> }



More information about the 2d-dev mailing list