-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
189 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace NetFabric.Numerics.Benchmarks; | ||
|
||
public class MathBenchmarks | ||
{ | ||
double[]? doubles; | ||
Angle<Radians, double>[]? angles; | ||
|
||
[Params(0, 1, 10, 1_000)] | ||
public int Count { get; set; } | ||
|
||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
doubles= new double[Count]; | ||
angles = new Angle<Radians, double>[Count]; | ||
|
||
for (var index = 0; index < Count; index++) | ||
{ | ||
doubles![index] = index; | ||
angles![index] = new Angle<Radians, double>(index); | ||
} | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public double Double() | ||
{ | ||
var sum = 0.0; | ||
foreach (var value in doubles!) | ||
sum += value; | ||
return sum; | ||
} | ||
|
||
[Benchmark] | ||
public Angle<Radians, double> Angle() | ||
{ | ||
Angle<Radians, double> sum = Angle<Radians, double>.Zero; | ||
foreach (var angle in angles!) | ||
sum += angle; | ||
return sum; | ||
} | ||
|
||
[Benchmark] | ||
public Angle<Radians, double> Mix() | ||
{ | ||
var sum = 0.0; | ||
foreach (var angle in angles!) | ||
sum += angle.Value; | ||
return new(sum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.