-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add system to the comparison benchmarks.
- Loading branch information
Showing
6 changed files
with
124 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Quantities.Prefixes; | ||
using Quantities.Units.Si; | ||
using Quantities.Units.Si.Metric; | ||
|
||
namespace Quantities.Benchmark.Compare; | ||
|
||
[MemoryDiagnoser] | ||
public class ComplexCreation | ||
{ | ||
private static readonly Double value = Math.E; | ||
|
||
[Benchmark(Baseline = true)] | ||
public Volume CreateQuantity() => Volume.Of(value).Cubic.Si<Centi, Metre>(); | ||
|
||
[Benchmark] | ||
public UnitsNet.Volume CreateUnitsNet() => UnitsNet.Volume.FromCubicCentimeters(value); | ||
|
||
[Benchmark] | ||
public Volume CreateQuantityCentiLitre() => Volume.Of(value).Metric<Centi, Litre>(); | ||
|
||
[Benchmark] | ||
public UnitsNet.Volume CreateUnitsNetCentiLitre() => UnitsNet.Volume.FromCentiliters(value); | ||
} | ||
/* | ||
// * Summary * | ||
BenchmarkDotNet v0.13.8, Arch Linux | ||
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores | ||
.NET SDK 7.0.111 | ||
[Host] : .NET 7.0.11 (7.0.1123.46301), X64 RyuJIT AVX2 | ||
DefaultJob : .NET 7.0.11 (7.0.1123.46301), X64 RyuJIT AVX2 | ||
| Method | Mean | Error | StdDev | Ratio | Allocated | Alloc Ratio | | ||
|------------------------- |---------:|---------:|---------:|------:|----------:|------------:| | ||
| CreateQuantity | 23.63 ns | 0.247 ns | 0.231 ns | 1.00 | - | NA | | ||
| CreateUnitsNet | 12.92 ns | 0.044 ns | 0.041 ns | 0.55 | - | NA | | ||
| CreateQuantityCentiLitre | 27.19 ns | 0.068 ns | 0.064 ns | 1.15 | - | NA | | ||
| CreateUnitsNetCentiLitre | 12.66 ns | 0.095 ns | 0.089 ns | 0.54 | - | NA | | ||
*/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Quantities.Prefixes; | ||
using Quantities.Units.Imperial.Length; | ||
using Quantities.Units.Si; | ||
using Quantities.Units.Si.Metric; | ||
using nLength = UnitsNet.Length; | ||
using nVolume = UnitsNet.Volume; | ||
|
||
namespace Quantities.Benchmark.Compare; | ||
|
||
[MemoryDiagnoser] | ||
public class Division | ||
{ | ||
private static readonly Volume left = Volume.Of(32).Metric<Centi, Litre>(); | ||
private static readonly Length right = Length.Of(4).Imperial<Foot>(); | ||
private static readonly nVolume nLeft = nVolume.FromCentiliters(32); | ||
private static readonly nLength nRight = nLength.FromFeet(4); | ||
|
||
[Benchmark(Baseline = true)] | ||
public Area Quantity() => left / right; | ||
|
||
[Benchmark] | ||
public UnitsNet.Area UnitsNet() => nLeft / nRight; | ||
} | ||
|
||
/* | ||
// * Summary * | ||
BenchmarkDotNet v0.13.8, Arch Linux | ||
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores | ||
.NET SDK 7.0.111 | ||
[Host] : .NET 7.0.11 (7.0.1123.46301), X64 RyuJIT AVX2 | ||
DefaultJob : .NET 7.0.11 (7.0.1123.46301), X64 RyuJIT AVX2 | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | | ||
|--------- |---------:|---------:|---------:|------:|--------:|----------:|------------:| | ||
| Quantity | 12.06 ns | 0.055 ns | 0.046 ns | 1.00 | 0.00 | - | NA | | ||
| UnitsNet | 80.38 ns | 0.243 ns | 0.216 ns | 6.66 | 0.03 | - | NA | | ||
*/ |
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,35 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Quantities.Prefixes; | ||
using Quantities.Units.Si; | ||
|
||
using nLength = UnitsNet.Length; | ||
|
||
namespace Quantities.Benchmark.Compare; | ||
|
||
[MemoryDiagnoser] | ||
public class ScalarCreation | ||
{ | ||
private static readonly Double value = Math.E; | ||
|
||
[Benchmark(Baseline = true)] | ||
public Length Quantity() => Length.Of(value).Si<Centi, Metre>(); | ||
|
||
[Benchmark] | ||
public nLength UnitsNet() => nLength.FromCentimeters(value); | ||
} | ||
|
||
/* | ||
// * Summary * | ||
BenchmarkDotNet v0.13.8, Arch Linux | ||
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores | ||
.NET SDK 7.0.111 | ||
[Host] : .NET 7.0.11 (7.0.1123.46301), X64 RyuJIT AVX2 | ||
DefaultJob : .NET 7.0.11 (7.0.1123.46301), X64 RyuJIT AVX2 | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | | ||
|--------- |---------:|---------:|---------:|------:|--------:|----------:|------------:| | ||
| Quantity | 10.68 ns | 0.150 ns | 0.141 ns | 1.00 | 0.00 | - | NA | | ||
| UnitsNet | 12.84 ns | 0.139 ns | 0.130 ns | 1.20 | 0.02 | - | NA | | ||
*/ |
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