Example usage for org.apache.commons.math3.random RandomGenerator getClass

List of usage examples for org.apache.commons.math3.random RandomGenerator getClass

Introduction

In this page you can find the example usage for org.apache.commons.math3.random RandomGenerator getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.github.joulupunikki.math.random.XorShift1024Star.java

public static double[] speedTest(RandomGenerator rng) {
    final int WARM_UP = 10000;
    final int S = 40;
    final int N = 1000000;
    double[] times = new double[S];
    for (int j = 0; j < S; j++) {

        System.gc();/*  www .ja va 2  s .  c  o m*/
        for (int i = 0; i < WARM_UP; i++) {
            rng.nextDouble();
        }
        long start = System.nanoTime();
        for (int i = 0; i < N; i++) {
            rng.nextDouble();
        }
        double time = System.nanoTime() - start;
        System.out.println("" + rng.getClass().getCanonicalName() + " " + time / 1000);
        times[j] = time;
    }
    Arrays.sort(times);
    return times;
}