
import java.util.*;
import java.util.concurrent.*;

public class NextDoubleLoops {
    static final long SIZE = 1L << 26;

    static SplittableRandom seeder = new SplittableRandom();

    public static void main(String[] args) throws Exception {
        SplittableRandom r = new SplittableRandom();
        for (long size = 1 << 10; size <= SIZE; size <<= 1) {
            t1(r.split(), size);
            //                t2(size);
            t3(size);
        }

        for (int i = 0; i < 5; ++i) {
            t1(r.split(), SIZE);
            //                t2(SIZE);
            t3(SIZE);
        }

    }

    static void t1(SplittableRandom r, long size) {
        //        SplittableRandom r = new SplittableRandom();
        double sum = 0;
        long now = System.nanoTime();
        for (int i = 0; i < size; ++i)
            sum += r.nextDouble();
        double ns = throughput(now, size);
        System.out.printf("SR  size: %10d mops: %10.1f\n", size, ns);
        if (sum == 0) System.out.println();
    }

    static void t2(long size) {
        ThreadLocalRandom r = ThreadLocalRandom.current();
        double sum = 0;
        long now = System.nanoTime();
        for (int i = 0; i < size; ++i)
            sum += r.nextDouble();
        double ns = throughput(now, size);
        System.out.printf("TLR size: %10d mops: %10.1f\n", size, ns);
        if (sum == 0) System.out.println();
    }

    static void t3(long size) {
        Random r = new Random();
        double sum = 0;
        long now = System.nanoTime();
        for (int i = 0; i < size; ++i)
            sum += r.nextDouble();
        double ns = throughput(now, size);
        System.out.printf("JUR size: %10d mops: %10.1f\n", size, ns);
        if (sum == 0) System.out.println();
    }

    static double opTime(long startTime, long nops) {
        return (double)(System.nanoTime() - startTime) / nops;
    }

    static double throughput(long startTime, long nops) {
        return (nops * 1000L) / (double)(System.nanoTime() - startTime);
    }

    static double elapsedTime(long startTime) {
        return (double)(System.nanoTime() - startTime) / (1000L * 1000 * 1000);
    }


}


