/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® quad-core |
Each table row shows performance measurements for this Java 7 program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 1,000 | 0.42 | 0.19 | ? | 903 | 42% 37% 95% 52% |
| 4,000 | 3.36 | 0.95 | 19,384 | 903 | 86% 86% 88% 96% |
| 16,000 | 45.30 | 11.46 | 69,716 | 903 | 99% 99% 99% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read mandelbrot benchmark to see what this program should do.
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
/* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Stefan Krause slightly modified by Chad Whipkey parallelized by Colin D Bennett 2008-10-04 reduce synchronization cost by The Anh Tran */ //package mandelbrot; import java.io.*; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; public final class mandelbrot { public static void main(String[] args) throws Exception { int size = 200; if (args.length >= 1) size = Integer.parseInt(args[0]); System.out.format("P4\n%d %d\n", size, size); int width_bytes = size /8 +1; byte[][] output_data = new byte[size][width_bytes]; int[] bytes_per_line = new int[size]; Compute(size, output_data, bytes_per_line); BufferedOutputStream ostream = new BufferedOutputStream(System.out); for (int i = 0; i < size; i++) ostream.write(output_data[i], 0, bytes_per_line[i]); ostream.close(); } private static final void Compute(final int N, final byte[][] output, final int[] bytes_per_line) { final double inverse_N = 2.0 / N; final AtomicInteger current_line = new AtomicInteger(0); final Thread[] pool = new Thread[Runtime.getRuntime().availableProcessors()]; for (int i = 0; i < pool.length; i++) { pool[i] = new Thread() { public void run() { int y; while ((y = current_line.getAndIncrement()) < N) { byte[] pdata = output[y]; int bit_num = 0; int byte_count = 0; int byte_accumulate = 0; double Civ = (double)y * inverse_N - 1.0; for (int x = 0; x < N; x++) { double Crv = (double)x * inverse_N - 1.5; double Zrv = Crv; double Ziv = Civ; double Trv = Crv * Crv; double Tiv = Civ * Civ; int i = 49; do { Ziv = (Zrv * Ziv) + (Zrv * Ziv) + Civ; Zrv = Trv - Tiv + Crv; Trv = Zrv * Zrv; Tiv = Ziv * Ziv; } while ( ((Trv + Tiv) <= 4.0) && (--i > 0)); byte_accumulate <<= 1; if (i == 0) byte_accumulate++; if (++bit_num == 8) { pdata[ byte_count++ ] = (byte)byte_accumulate; bit_num = byte_accumulate = 0; } } // end foreach column if (bit_num != 0) { byte_accumulate <<= (8 - (N & 7)); pdata[ byte_count++ ] = (byte)byte_accumulate; } bytes_per_line[y] = byte_count; } // end while (y < N) } // end void run() }; // end inner class definition pool[i].start(); } for (Thread t : pool) { try { t.join(); } catch (InterruptedException e) { e.printStackTrace(); } } } }
Sun, 20 Jan 2013 15:47:56 GMT MAKE: mv mandelbrot.java-3.java mandelbrot.java /usr/local/src/jdk1.7.0_11/bin/javac mandelbrot.java 0.74s to complete and log all make actions COMMAND LINE: /usr/local/src/jdk1.7.0_11/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts mandelbrot 16000 (BINARY) PROGRAM OUTPUT NOT SHOWN