Class ConstructionPerformance
- java.lang.Object
-
- org.apache.commons.rng.examples.jmh.simple.ConstructionPerformance
-
public class ConstructionPerformance extends Object
Executes a benchmark to compare the speed of construction of random number providers.Note that random number providers are created and then used. Thus the construction time must be analysed together with the run time performance benchmark (see for example
NextIntGenerationPerformanceandNextLongGenerationPerformance).[Total time] = [Construction time] + [Run time]
Selection of a suitable random number provider based on construction speed should consider when the construction time is a large fraction of the run time. In the majority of cases the run time will be the largest component of the total time and the provider should be selected based on its other properties such as the period, statistical randomness and speed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstructionPerformance.IntSizesThe number ofintvalues that are required to seed a generator.static classConstructionPerformance.LongSizesThe number oflongvalues that are required to seed a generator.static classConstructionPerformance.SourcesThe benchmark state (retrieve the various "RandomSource"s).
-
Constructor Summary
Constructors Constructor Description ConstructionPerformance()Default constructor to initialize state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbaselineConsumeObject(org.openjdk.jmh.infra.Blackhole bh)Baseline for JMH consuming a number of constructed objects.voidcreateByteArray(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)voidcreateIntArraySeed(ConstructionPerformance.IntSizes sizes, org.openjdk.jmh.infra.Blackhole bh)voidcreateLongArraySeed(ConstructionPerformance.LongSizes sizes, org.openjdk.jmh.infra.Blackhole bh)voidcreateLongSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)voidcreateNativeSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)voidcreateNullSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)voidcreateSelfSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)Test the native seed with arrays truncated to length 1.voidcreateSingleIntegerSeed(org.openjdk.jmh.infra.Blackhole bh)voidcreateSingleLongSeed(org.openjdk.jmh.infra.Blackhole bh)voidlookupNewInstance(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)Create a new instance using reflection to lookup the constructor then invoke it.voidnewInstance(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)Create a new instance using reflection with a cached constructor.voidnewISAACRandom(org.openjdk.jmh.infra.Blackhole bh)voidnewJDKRandom(org.openjdk.jmh.infra.Blackhole bh)voidnewKISSRandom(org.openjdk.jmh.infra.Blackhole bh)voidnewMersenneTwister(org.openjdk.jmh.infra.Blackhole bh)voidnewMersenneTwister64(org.openjdk.jmh.infra.Blackhole bh)voidnewMultiplyWithCarry256(org.openjdk.jmh.infra.Blackhole bh)voidnewObject(org.openjdk.jmh.infra.Blackhole bh)Baseline for JMH consuming a number of new objects.voidnewPhilox4x32(org.openjdk.jmh.infra.Blackhole bh)voidnewPhilox4x64(org.openjdk.jmh.infra.Blackhole bh)voidnewSplitMix64(org.openjdk.jmh.infra.Blackhole bh)voidnewTwoCmres(org.openjdk.jmh.infra.Blackhole bh)voidnewWell1024a(org.openjdk.jmh.infra.Blackhole bh)voidnewWell19937a(org.openjdk.jmh.infra.Blackhole bh)voidnewWell19937c(org.openjdk.jmh.infra.Blackhole bh)voidnewWell44497a(org.openjdk.jmh.infra.Blackhole bh)voidnewWell44497b(org.openjdk.jmh.infra.Blackhole bh)voidnewWell512a(org.openjdk.jmh.infra.Blackhole bh)voidnewXoRoShiRo128Plus(org.openjdk.jmh.infra.Blackhole bh)voidnewXoRoShiRo128StarStar(org.openjdk.jmh.infra.Blackhole bh)voidnewXoRoShiRo64Star(org.openjdk.jmh.infra.Blackhole bh)voidnewXoRoShiRo64StarStar(org.openjdk.jmh.infra.Blackhole bh)voidnewXorShift1024Star(org.openjdk.jmh.infra.Blackhole bh)voidnewXorShift1024StarPhi(org.openjdk.jmh.infra.Blackhole bh)voidnewXoShiRo128Plus(org.openjdk.jmh.infra.Blackhole bh)voidnewXoShiRo128StarStar(org.openjdk.jmh.infra.Blackhole bh)voidnewXoShiRo256Plus(org.openjdk.jmh.infra.Blackhole bh)voidnewXoShiRo256StarStar(org.openjdk.jmh.infra.Blackhole bh)voidnewXoShiRo512Plus(org.openjdk.jmh.infra.Blackhole bh)voidnewXoShiRo512StarStar(org.openjdk.jmh.infra.Blackhole bh)
-
-
-
Constructor Detail
-
ConstructionPerformance
public ConstructionPerformance()
Default constructor to initialize state.
-
-
Method Detail
-
baselineConsumeObject
public void baselineConsumeObject(org.openjdk.jmh.infra.Blackhole bh)
Baseline for JMH consuming a number of constructed objects. This shows the JMH timing overhead for all the construction benchmarks.- Parameters:
bh- Data sink.
-
newObject
public void newObject(org.openjdk.jmh.infra.Blackhole bh)
Baseline for JMH consuming a number of new objects.- Parameters:
bh- Data sink.
-
newJDKRandom
public void newJDKRandom(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newWell512a
public void newWell512a(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newWell1024a
public void newWell1024a(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newWell19937a
public void newWell19937a(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newWell19937c
public void newWell19937c(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newWell44497a
public void newWell44497a(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newWell44497b
public void newWell44497b(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newMersenneTwister
public void newMersenneTwister(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newISAACRandom
public void newISAACRandom(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newSplitMix64
public void newSplitMix64(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXorShift1024Star
public void newXorShift1024Star(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newTwoCmres
public void newTwoCmres(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newMersenneTwister64
public void newMersenneTwister64(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newMultiplyWithCarry256
public void newMultiplyWithCarry256(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newKISSRandom
public void newKISSRandom(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXorShift1024StarPhi
public void newXorShift1024StarPhi(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoRoShiRo64Star
public void newXoRoShiRo64Star(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoRoShiRo64StarStar
public void newXoRoShiRo64StarStar(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoShiRo128Plus
public void newXoShiRo128Plus(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoShiRo128StarStar
public void newXoShiRo128StarStar(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoRoShiRo128Plus
public void newXoRoShiRo128Plus(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoRoShiRo128StarStar
public void newXoRoShiRo128StarStar(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoShiRo256Plus
public void newXoShiRo256Plus(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoShiRo256StarStar
public void newXoShiRo256StarStar(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoShiRo512Plus
public void newXoShiRo512Plus(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newXoShiRo512StarStar
public void newXoShiRo512StarStar(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newPhilox4x32
public void newPhilox4x32(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newPhilox4x64
public void newPhilox4x64(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
newInstance
public void newInstance(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh) throws InstantiationException, IllegalAccessException, InvocationTargetException
Create a new instance using reflection with a cached constructor.- Parameters:
sources- Source of randomness.bh- Data sink.- Throws:
InvocationTargetException- If reflection failed.IllegalAccessException- If reflection failed.InstantiationException- If reflection failed.
-
lookupNewInstance
public void lookupNewInstance(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
Create a new instance using reflection to lookup the constructor then invoke it.- Parameters:
sources- Source of randomness.bh- Data sink.- Throws:
InvocationTargetException- If reflection failed.IllegalAccessException- If reflection failed.InstantiationException- If reflection failed.SecurityException- If reflection failed.NoSuchMethodException- If reflection failed.IllegalArgumentException- If reflection failed.
-
createNullSeed
public void createNullSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
sources- Source of randomness.bh- Data sink.
-
createNativeSeed
public void createNativeSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
sources- Source of randomness.bh- Data sink.
-
createSelfSeed
public void createSelfSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)
Test the native seed with arrays truncated to length 1. This tests the speed of self-seeding.This test is the same as
createNativeSeed(Sources, Blackhole)if the random source native seed is not an array.- Parameters:
sources- Source of randomness.bh- Data sink.
-
createLongSeed
public void createLongSeed(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
sources- Source of randomness.bh- Data sink.
-
createByteArray
public void createByteArray(ConstructionPerformance.Sources sources, org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
sources- Source of randomness.bh- Data sink.
-
createIntArraySeed
public void createIntArraySeed(ConstructionPerformance.IntSizes sizes, org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
sizes- Size ofint[]seed.bh- Data sink.
-
createLongArraySeed
public void createLongArraySeed(ConstructionPerformance.LongSizes sizes, org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
sizes- Size oflong[]seed.bh- Data sink.
-
createSingleIntegerSeed
public void createSingleIntegerSeed(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
createSingleLongSeed
public void createSingleLongSeed(org.openjdk.jmh.infra.Blackhole bh)
- Parameters:
bh- Data sink.
-
-