Class Benchmark

java.lang.Object
cern.jet.random.engine.Benchmark

public class Benchmark extends Object
Benchmarks the performance of the currently provided uniform pseudo-random number generation engines.

All distributions are obtained by using a uniform pseudo-random number generation engine. followed by a transformation to the desired distribution. Therefore, the performance of the uniform engines is crucial.

Comparison of uniform generation engines

Name Period

Speed
[# million uniform random numbers generated/sec]
Pentium Pro 200 Mhz, JDK 1.2, NT

MersenneTwister 219937-1 (=106001) 2.5
Ranlux (default luxury level 3) 10171 0.4
Ranmar 1043 1.6
Ranecu 1018 1.5
java.util.Random.nextFloat() ? 2.4

Note: Methods working on the default uniform random generator are synchronized and therefore in current VM's slow (as of June '99). Methods taking as argument a uniform random generator are not synchronized and therefore much quicker. Thus, if you need a lot of random numbers, you should use the unsynchronized approach:

Example usage:

 edu.cornell.lassp.houle.RngPack.RandomElement generator;
 generator = new cern.jet.random.engine.MersenneTwister(new java.util.Date());
 //generator = new edu.cornell.lassp.houle.RngPack.Ranecu(new java.util.Date());
 //generator = new edu.cornell.lassp.houle.RngPack.Ranmar(new java.util.Date());
 //generator = new edu.cornell.lassp.houle.RngPack.Ranlux(new java.util.Date());
 //generator = makeDefaultGenerator();
 for (int i=1000000; --i >=0; ) {
    double uniform = generator.raw();
    ...
 }
 
Version:
1.0, 09/24/99
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Makes this class non instantiable, but still let's others inherit from it.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    benchmark(int times)
    Benchmarks raw() for various uniform generation engines.
    static void
    main(String[] args)
    Tests various methods of this class.
    static void
    test(int size, RandomEngine randomEngine)
    Prints the first size random numbers generated by the given engine.
    private static void
    xtestRandomFromTo(long from, long to, int times)
    Tests various methods of this class.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Benchmark

      protected Benchmark()
      Makes this class non instantiable, but still let's others inherit from it.
  • Method Details

    • benchmark

      public static void benchmark(int times)
      Benchmarks raw() for various uniform generation engines.
    • main

      public static void main(String[] args)
      Tests various methods of this class.
    • test

      public static void test(int size, RandomEngine randomEngine)
      Prints the first size random numbers generated by the given engine.
    • xtestRandomFromTo

      private static void xtestRandomFromTo(long from, long to, int times)
      Tests various methods of this class.