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 class
SinCosPerformance.BaseNumbers
Contains an array of numbers.static class
SinCosPerformance.Numbers
Contains an array of numbers.static class
SinCosPerformance.NumberSize
Contains the size of numbers.static class
SinCosPerformance.UniformNumbers
Contains an array of uniform numbers.
-
Constructor Summary
Constructors Constructor Description SinCosPerformance()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
baselineIdentity(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
Baseline the JMH overhead for all the benchmarks that create numbers.void
fastMathCos(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkFastMath.cos(double)
.void
fastMathSin(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkFastMath.sin(double)
.void
mathCos(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkMath.cos(double)
.void
mathSin(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkMath.sin(double)
.void
mathSin2(SinCosPerformance.Numbers numbers, org.openjdk.jmh.infra.Blackhole bh)
Explicit benchmark without using a method reference.void
rangeFastMathSin(SinCosPerformance.UniformNumbers numbers, org.openjdk.jmh.infra.Blackhole bh)
BenchmarkFastMath.sin(double)
using a uniform range of numbers.void
rangeMathSin(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.
-
-