performance measurements

Each table row shows performance measurements for this Java program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
500,0005.494.4322,048473  12% 32% 43% 17%
5,000,00051.2341.9121,780473  22% 26% 24% 27%
50,000,000499.14373.9621,876473  26% 27% 27% 26%

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.

 notes

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Server VM (build 25.0-b70, mixed mode)

 thread-ring Java #7 program source code

/**

 * The Computer Language Benchmarks Game

 * http://benchmarksgame.alioth.debian.org/

 * contributed by Klaus Friedel

 * modified by Daryl Griffith

 */

import java.util.concurrent.locks.LockSupport;

public class threadring extends Thread {

    static final int THREAD_COUNT = 503;

    threadring nextThread;
    volatile boolean waiting = true;
    int message;

    public threadring(int name) {
        super(Integer.toString(name));
    }

    @Override
    public void run() {
        for (;;) {
            while (waiting) {
                LockSupport.park();
            }
            if (message == 0) {
                System.out.println(getName());
                System.exit(0);
            }
            waiting = true;
            nextThread.message = message - 1;
            nextThread.waiting = false;
            LockSupport.unpark(nextThread);
        }
    }

    public static void main(String args[]) throws Exception {
        threadring first = new threadring(1);
        threadring current = new threadring(2);

        first.start(); // Thread 1

        first.nextThread = current;
        first.message = Integer.parseInt(args[0]);
        first.waiting = false;
        for (int i = 3; i < THREAD_COUNT; i++) {
            current.nextThread = new threadring(i);
            current.start();
            current = current.nextThread;
        }
        current.nextThread = new threadring(THREAD_COUNT);
        current.start(); // Thread 502

        current = current.nextThread;
        current.nextThread = first;
        current.start(); // Thread 503

    }
}

 make, command-line, and program output logs

Wed, 19 Mar 2014 08:05:23 GMT

MAKE:
mv threadring.java-7.java threadring.java
/usr/local/src/jdk1.8.0/bin/javac threadring.java
0.76s to complete and log all make actions

COMMAND LINE:
/usr/local/src/jdk1.8.0/bin/java  -server -XX:+TieredCompilation -XX:+AggressiveOpts threadring 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play