// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.security.SecureRandom;
import java.util.Random;

public class RngTimes {
    private static final int NP = 1_000_000_000;
    private static final int NCSP = 100_000_000;
    public static void main(String[] args) {
        long t1 = System.currentTimeMillis();
        Random prng = new Random();
        for(int i = 0; i < NP; i++) {
            int v = prng.nextInt(256);
            if(v < 0) throw new RuntimeException("Never gonna happen");
        }
        long t2 = System.currentTimeMillis();
        System.out.printf("%10.0f per sec%n", NP * 1000.0 / (t2 - t1));
        long t3 = System.currentTimeMillis();
        Random csprng = new SecureRandom();
        for(int i = 0; i < NCSP; i++) {
            int v = csprng.nextInt(256);
            if(v < 0) throw new RuntimeException("Never gonna happen");
        }
        long t4 = System.currentTimeMillis();
        System.out.printf("%10.0f per sec%n", NCSP * 1000.0 / (t4 - t3));
    }
}
