/mobile Handheld Friendly website

 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,0001.021.0330,464432  0% 2% 0% 99%
5,000,0003.813.8248,356432  1% 1% 1% 100%
50,000,00017.2717.2897,864432  1% 1% 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.

 notes

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

 thread-ring Java #5 program source code

/**
 * The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 * contributed by Birju Prajapati
 */

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class threadring {

    private static final int TOTAL_NODES = 503;
    private static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(TOTAL_NODES);
    
    private static Node firstNode;
    private static Node lastNode;

    public static void main(String[] args) {
        firstNode = new Node(1);
        lastNode.next = firstNode;
        firstNode.push(Integer.parseInt(args[0]));
    }

    private static class Node implements Runnable {

        private final int id;
        private Node next;
        private int token;

        public Node(int id) {
            this.id = id;
            if (id++ == TOTAL_NODES) {
                lastNode = this;
            } else {
                next = new Node(id);
            }
        }

        private void push(int token) {
            this.token = token;
            EXECUTOR.execute(this);
        }

        public void run() {
            if (token-- != 0) {
                next.push(token);
            } else {
                System.out.println(id);
                System.exit(0);
            }
            
        }
    }
}


 make, command-line, and program output logs

Wed, 19 Mar 2014 13:53:29 GMT

MAKE:
mv threadring.java-5.java threadring.java
/usr/local/src/jdk1.8.0/bin/javac threadring.java
0.71s 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