
C# beats Java in 9 out of 10 benchmarks (benchmarks game) - superjan
https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/csharp.html
======
sorokod
Not sure what the output of Java Mandelbrot supposed to produce - it really
does a number on the terminal.

Anyway, the original version spends half of it's time writing to stdout,
verify by replacing

    
    
        OutputStream stream = new BufferedOutputStream(System.out);
    

with

    
    
        OutputStream stream = new BufferedOutputStream(new FileOutputStream("./mandel_out"));	
    

The time can be cut in half again by not using AtomicInteger (it is heavily
contended) and having every thread operate on it's own chunk of the out array
without any synchronization.

~~~
igouy
> writing to stdout

rtm "with output redirected to /dev/null" !

[https://benchmarksgame-
team.pages.debian.net/benchmarksgame/...](https://benchmarksgame-
team.pages.debian.net/benchmarksgame/how-programs-are-measured.html#measured)

> new BufferedOutputStream(System.out);
    
    
        $ time /opt/src/jdk-10.0.1/bin/java   mandelbrot 16000 > /dev/null
    
        real	0m7.144s
        user	0m27.405s
        sys	        0m0.156s
    
    

> new FileOutputStream("./mandel_out")
    
    
        $ time /opt/src/jdk-10.0.1/bin/java   mandelbrot 16000 
    
        real	0m7.125s
        user	0m27.367s
        sys	        0m0.184s

~~~
sorokod
Yup - writing to disk it pretty fast. Not sure what your point is though as
according to [https://benchmarksgame-
team.pages.debian.net/benchmarksgame/...](https://benchmarksgame-
team.pages.debian.net/benchmarksgame/program/mandelbrot-java-2.html) the
output for the benchmark is _not_ redirected to /dev/null :

    
    
        COMMAND LINE:
        /opt/src/jdk-10.0.1/bin/java   mandelbrot 16000

~~~
igouy
rtm

"1\. Each program is run and measured at the smallest input value, _program
output redirected to a file_ and compared to expected output. As long as the
output matches expected output, the program is then run and measured at the
next larger input value until measurements have been made at every input
value."

