Class SinCosPerformance
- java.lang.Object
-
- org.apache.commons.numbers.examples.jmh.complex.SinCosPerformance
-
- Direct Known Subclasses:
SinCosPerformance_jmhType_B1
public class SinCosPerformance extends Object
Executes a benchmark to estimate the speed of sin/cos operations. This compares the Math implementation to FastMath. It would be possible to adapt FastMath to compute sin/cos together as they both use a common initial stage to map the value to the domain [0, pi/2).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSinCosPerformance.BaseNumbersContains an array of numbers.static classSinCosPerformance.NumbersContains an array of numbers.static classSinCosPerformance.NumberSizeContains the size of numbers.static classSinCosPerformance.UniformNumbersContains an array of uniform numbers.
-
Constructor Summary
Constructors Constructor Description SinCosPerformance()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbaselineIdentity(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)Baseline the JMH overhead for all the benchmarks that create numbers.voidfastMathCos(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)BenchmarkFastMath.cos(double).voidfastMathSin(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)BenchmarkFastMath.sin(double).voidmathCos(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)BenchmarkMath.cos(double).voidmathSin(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)BenchmarkMath.sin(double).voidmathSin2(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)Explicit benchmark without using a method reference.voidrangeFastMathSin(SinCosPerformance.UniformNumbers numbers, org.openjdk.jmh.infra.Blackhole bh)BenchmarkFastMath.sin(double)using a uniform range of numbers.voidrangeMathSin(SinCosPerformance.UniformNumbers numbers, org.openjdk.jmh.infra.Blackhole bh)BenchmarkMath.sin(double)using a uniform range of numbers.
-
-
-
Method Detail
-
mathSin2
public void mathSin2(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
Explicit benchmark without using a method reference. This is commented out as it exists for reference purposes.- Parameters:
numbers- Numbers.bh- Data sink.
-
baselineIdentity
public void baselineIdentity(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
Baseline the JMH overhead for all the benchmarks that create numbers. All other methods are expected to be slower than this.- Parameters:
numbers- Numbers.bh- Data sink.
-
mathSin
public void mathSin(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkMath.sin(double).- Parameters:
numbers- Numbers.bh- Data sink.
-
mathCos
public void mathCos(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkMath.cos(double).- Parameters:
numbers- Numbers.bh- Data sink.
-
fastMathSin
public void fastMathSin(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkFastMath.sin(double).- Parameters:
numbers- Numbers.bh- Data sink.
-
fastMathCos
public void fastMathCos(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkFastMath.cos(double).- Parameters:
numbers- Numbers.bh- Data sink.
-
rangeMathSin
public void rangeMathSin(SinCosPerformance.UniformNumbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkMath.sin(double)using a uniform range of numbers.- Parameters:
numbers- Numbers.bh- Data sink.
-
rangeFastMathSin
public void rangeFastMathSin(SinCosPerformance.UniformNumbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkFastMath.sin(double)using a uniform range of numbers.- Parameters:
numbers- Numbers.bh- Data sink.
-
-