/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® one 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 |
|---|---|---|---|---|---|
| 500,000 | 2.65 | 2.67 | 30,540 | 530 | 0% 0% 0% 99% |
| 5,000,000 | 23.07 | 23.10 | 38,588 | 530 | 0% 0% 0% 100% |
| 50,000,000 | 221.09 | 221.26 | 290,804 | 530 | 0% 0% 0% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read thread-ring 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 Klaus Friedel */ import java.util.concurrent.locks.LockSupport; public class threadring { static final int THREAD_COUNT = 503; public static class MessageThread extends Thread { MessageThread nextThread; volatile Integer message; public MessageThread(MessageThread nextThread, int name) { super(""+name); this.nextThread = nextThread; } public void run() { while(true) nextThread.enqueue(dequeue()); } public void enqueue(Integer hopsRemaining) { if(hopsRemaining == 0){ System.out.println(getName()); System.exit(0); } // as only one message populates the ring, it's impossible // that queue is not empty message = hopsRemaining - 1; LockSupport.unpark(this); // work waiting... } private Integer dequeue(){ while(message == null){ LockSupport.park(); } Integer msg = message; message = null; return msg; } } public static void main(String args[]) throws Exception{ int hopCount = Integer.parseInt(args[0]); MessageThread first = null; MessageThread last = null; for (int i = THREAD_COUNT; i >= 1 ; i--) { first = new MessageThread(first, i); if(i == THREAD_COUNT) last = first; } // close the ring: last.nextThread = first; // start all Threads MessageThread t = first; do{ t.start(); t = t.nextThread; }while(t != first); // inject message first.enqueue(hopCount); first.join(); // wait for System.exit } }
Sun, 20 Jan 2013 19:31:55 GMT MAKE: mv threadring.java-3.java threadring.java /usr/local/src/jdk1.7.0_11/bin/javac threadring.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 threadring 50000000 PROGRAM OUTPUT: 292