From: Isaac Gouy Date: 2006-08-04T01:25:07+09:00 Subject: Re: For performance, fix the Java program Peter Hickman wrote: > Charles O Nutter wrote: > > I'd be interested in seeing all of these run without IO as well...that > > was > > the big bottleneck for Java. > > Can we just clear something up here. The Latin squares mini project was > not plucked out of the air just to be a poster child for my first post. > It was part of a project that I am working on and as such the program > has to produce some output! It does not make any sense to optimise the > program in any language if we are not going to produce any output. > Otherwise I would go with this heavily optimised C version: > > [peterhickman]$ cat latin.c > int > main(int argc, char *argv[]) > { > return 0; > } > > This is an application, it has to produce output. Cease this willy > waving otherwise you are saying "For performance, remove the output". 1) Over the past 3 or 4 days, people have said what's wrong with the way you're producing output in Java, and suggested what you should do instead. Is it that you don't know enough Java to follow their suggestions and fix the program? A couple of days ago single measurements on my machine gave 0.820s user+sys, gcc -pipe -Wall -O3 -fomit-frame-pointer -funroll-loops -march=pentium4 4.444s user+sys, sun-jdk-1.5.0.07 Simply writing Java that converts the double-byte Unicode Java outputStrings to single-byte /once/ instead of everytime there's a print statement, and following the usual Java pattern of wrapping output with a BufferedOutputStream, reduces that to 1.396s user+sys, sun-jdk-1.5.0.07 Yesterday I emailed you another version of your Java generating Perl script that fixes those print problems, the output matches the C program output. 2) If this is an application, and it has to produce output, and it has to produce output for something larger than 6x6, then I think you need a better algorithm. You've mentioned the 5x5 C program took 2.473s, and the 6x6 took 9900s - at that rate might we expect 7x7 in 15 months?