-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolynomialBenchmark.cs
More file actions
39 lines (31 loc) · 1.48 KB
/
Copy pathPolynomialBenchmark.cs
File metadata and controls
39 lines (31 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Quantities.Core.Numerics;
using static Quantities.Benchmark.Convenience;
using static Quantities.Benchmark.Numerics.Trivial;
namespace Quantities.Benchmark.Numerics;
public class PolynomialBenchmark
{
private const Double scale = Math.E;
private const Double offset = Math.Tau + Math.E;
private const Double argument = 0.1321;
private static readonly (Double, Double, Double) trivial = (3d, 4d, -1d);
private static readonly Polynomial polynomial = Poly(nominator: scale, denominator: Math.PI, offset: offset);
private static readonly Polynomial polynomialWithoutOffset = Poly(nominator: scale, denominator: Math.PI);
[Benchmark(Baseline = true)]
public Double EvaluateTrivial() => Poly(in trivial, argument);
[Benchmark]
public Double EvaluatePolynomial() => polynomial * argument;
[Benchmark]
public Double EvaluatePolynomialWithoutOffset() => polynomialWithoutOffset * argument;
}
/* Summary *
BenchmarkDotNet v0.13.12, Arch Linux ARM
ARMv7 Processor rev 4 (v7l), 4 logical cores
.NET SDK 8.0.101
[Host] : .NET 8.0.1 (8.0.123.58001), Arm RyuJIT
DefaultJob : .NET 8.0.1 (8.0.123.58001), Arm RyuJIT
| Method | Mean | Error | Ratio |
|-------------------------------- |----------:|---------:|------:|-
| EvaluateTrivial | 38.63 ns | 1.069 ns | 1.00 |
| EvaluatePolynomial | 201.22 ns | 3.234 ns | 5.21 |
| EvaluatePolynomialWithoutOffset | 198.71 ns | 3.784 ns | 5.16 |
*/