Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to .Net 8.0 #42

Merged
merged 9 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions source/Quantities.Benchmark/AddingQuantities.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Diagnosers;
using Quantities.Prefixes;
using Quantities.Units.Imperial.Length;
using Quantities.Units.Si;

namespace Quantities.Benchmark;

[MemoryDiagnoser]
[MemoryDiagnoser(displayGenColumns: false)]
public class AddingQuantities
{
private Length sameMetric = Length.Of(-7, Si<Kilo, Metre>());
Expand All @@ -32,21 +32,20 @@ public class AddingQuantities
public Double AddMixed() => this.smallMetric + this.largeImperial;
}

/*
// * Summary *
/* Summary *

BenchmarkDotNet v0.13.8, Arch Linux
BenchmarkDotNet v0.13.10, Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 7.0.113
[Host] : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2


| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio |
|------------ |----------:|----------:|----------:|------:|--------:|----------:|------------:|
| Trivial | 1.6263 ns | 0.0347 ns | 0.0325 ns | 1.00 | 0.00 | - | NA |
| AddSi | 3.2011 ns | 0.0293 ns | 0.0274 ns | 1.97 | 0.05 | - | NA |
| AddSiSame | 0.8805 ns | 0.0386 ns | 0.0361 ns | 0.54 | 0.03 | - | NA |
| AddImperial | 3.2012 ns | 0.0227 ns | 0.0213 ns | 1.97 | 0.04 | - | NA |
| AddMixed | 3.3678 ns | 0.0720 ns | 0.0638 ns | 2.07 | 0.07 | - | NA |
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|------------ |----------:|----------:|------:|----------:|------------:|
| Trivial | 1.4131 ns | 0.0185 ns | 1.00 | - | NA |
| AddSi | 2.5279 ns | 0.0790 ns | 1.78 | - | NA |
| AddSiSame | 0.7713 ns | 0.0469 ns | 0.54 | - | NA |
| AddImperial | 2.4031 ns | 0.0066 ns | 1.70 | - | NA |
| AddMixed | 2.4445 ns | 0.0193 ns | 1.73 | - | NA |
*/
25 changes: 12 additions & 13 deletions source/Quantities.Benchmark/AllocationFreeBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Quantities.Benchmark;
namespace Quantities.Benchmark;

file interface IFactory<out T>
{
Expand All @@ -18,7 +18,7 @@ file static class AllocationFreeFactory<T>
public static T Item { get; } = T.Create();
}

[MemoryDiagnoser]
[MemoryDiagnoser(displayGenColumns: false)]
public class AllocationFreeBenchmark
{
[Benchmark(Baseline = true)]
Expand All @@ -31,19 +31,18 @@ public class AllocationFreeBenchmark
public Object AllocationFreeFactory() => AllocationFreeFactory<MyClass>.Item;
}

/*
// * Summary *
/* Summary *

BenchmarkDotNet v0.13.8, Arch Linux
BenchmarkDotNet v0.13.10, 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
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio |
|---------------------- |----------:|----------:|----------:|------:|-------:|----------:|------------:|
| Constructor | 6.3850 ns | 0.0400 ns | 0.0374 ns | 1.00 | 0.0057 | 24 B | 1.00 |
| AllocationFree | 0.5961 ns | 0.0192 ns | 0.0179 ns | 0.09 | - | - | 0.00 |
| AllocationFreeFactory | 0.5799 ns | 0.0207 ns | 0.0194 ns | 0.09 | - | - | 0.00 |
| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|---------------------- |----------:|----------:|------:|----------:|------------:|
| Constructor | 6.5466 ns | 0.0194 ns | 1.00 | 24 B | 1.00 |
| AllocationFree | 0.6569 ns | 0.0077 ns | 0.10 | - | 0.00 |
| AllocationFreeFactory | 0.6458 ns | 0.0728 ns | 0.10 | - | 0.00 |
*/
25 changes: 12 additions & 13 deletions source/Quantities.Benchmark/ConversionBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using Quantities.Core.Numerics;

namespace Quantities.Benchmark;
Expand Down Expand Up @@ -51,20 +51,19 @@ file static class Cache<TFrom, TTo>
public static Double Convert(in Double value) => polynomial * value;
}

/*
// * Summary *
/* Summary *

BenchmarkDotNet v0.13.8, Arch Linux
BenchmarkDotNet v0.13.10, 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
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean | Error | StdDev | Ratio |
|----------------------- |---------:|----------:|----------:|------:|
| EvaluateTrivial | 2.576 ns | 0.0175 ns | 0.0164 ns | 1.00 |
| EvaluateSuccessive | 1.672 ns | 0.0134 ns | 0.0119 ns | 0.65 |
| EvaluateCached | 1.573 ns | 0.0087 ns | 0.0068 ns | 0.61 |
| EvaluateArithmetically | 1.735 ns | 0.0099 ns | 0.0078 ns | 0.67 |
| Method | Mean | Error | Ratio |
|----------------------- |----------:|----------:|------:|
| EvaluateTrivial | 3.1148 ns | 0.0791 ns | 1.00 |
| EvaluateSuccessive | 0.8463 ns | 0.0224 ns | 0.27 |
| EvaluateCached | 1.2761 ns | 0.0175 ns | 0.41 |
| EvaluateArithmetically | 0.1341 ns | 0.0054 ns | 0.04 |
*/
27 changes: 13 additions & 14 deletions source/Quantities.Benchmark/ConvertingQuantities.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Quantities.Prefixes;
using Quantities.Prefixes;
using Quantities.Units.Imperial.Length;
using Quantities.Units.Si;
using Quantities.Units.Si.Derived;

namespace Quantities.Benchmark;

[MemoryDiagnoser]
[MemoryDiagnoser(displayGenColumns: false)]
public class ConvertingQuantities
{
private const Double feetToMetre = 0.3048;
Expand All @@ -27,20 +27,19 @@ public class ConvertingQuantities
public Double QuantityToVeryDifferent() => energy.To(Si<Kilo, Watt>().Times(Si<Milli, Second>()));
}

/*
// * Summary *
/* Summary *

BenchmarkDotNet v0.13.8, Arch Linux
BenchmarkDotNet v0.13.10, Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 7.0.113
[Host] : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio |
|------------------------ |-----------:|----------:|----------:|------:|--------:|----------:|------------:|
| TrivialImplementation | 0.6200 ns | 0.0304 ns | 0.0284 ns | 1.00 | 0.00 | - | NA |
| QuantityImplementation | 4.0954 ns | 0.0377 ns | 0.0315 ns | 6.64 | 0.34 | - | NA |
| QuantityToSame | 14.5757 ns | 0.0652 ns | 0.0610 ns | 23.55 | 1.02 | - | NA |
| QuantityToVeryDifferent | 16.9657 ns | 0.1247 ns | 0.1041 ns | 27.49 | 1.41 | - | NA |
| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|------------------------ |----------:|----------:|------:|----------:|------------:|
| TrivialImplementation | 2.374 ns | 0.0081 ns | 1.00 | - | NA |
| QuantityImplementation | 4.316 ns | 0.0176 ns | 1.82 | - | NA |
| QuantityToSame | 14.429 ns | 0.0546 ns | 6.08 | - | NA |
| QuantityToVeryDifferent | 15.515 ns | 0.0696 ns | 6.53 | - | NA |
*/
41 changes: 20 additions & 21 deletions source/Quantities.Benchmark/CreateQuantities.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Diagnosers;
using Quantities.Prefixes;
using Quantities.Units.Si;
Expand Down Expand Up @@ -30,7 +30,7 @@ public sealed class DummyObject : ICastOperators<DummyObject, Double>
public static implicit operator Double(DummyStruct obj) => obj.value.Value;
}

[MemoryDiagnoser]
[MemoryDiagnoser(displayGenColumns: false)]
//[EventPipeProfiler(EventPipeProfile.CpuSampling)]
public class CreateQuantities
{
Expand Down Expand Up @@ -68,25 +68,24 @@ public class CreateQuantities
public Area CreateSquarePowerQuantity() => Area.Of(in this.value, Square(Si<Metre>()));
}

/*
// * Summary *
/* Summary *

BenchmarkDotNet v0.13.8, Arch Linux
BenchmarkDotNet v0.13.10, Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 7.0.113
[Host] : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2


| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|------------------------------- |----------:|----------:|----------:|------:|--------:|-------:|----------:|------------:|
| CreateObject | 6.246 ns | 0.0758 ns | 0.0709 ns | 1.00 | 0.00 | 0.0057 | 24 B | 1.00 |
| CreateStruct | 1.690 ns | 0.0197 ns | 0.0185 ns | 0.27 | 0.01 | - | - | 0.00 |
| CreateScalarQuantity | 5.816 ns | 0.0224 ns | 0.0210 ns | 0.93 | 0.01 | - | - | 0.00 |
| CreateScalarQuantityWithoutOpt | 5.534 ns | 0.0180 ns | 0.0160 ns | 0.89 | 0.01 | - | - | 0.00 |
| CreateQuotientQuantity | 16.178 ns | 0.1976 ns | 0.1849 ns | 2.59 | 0.04 | - | - | 0.00 |
| CreateProductQuantity | 16.342 ns | 0.1430 ns | 0.1338 ns | 2.62 | 0.03 | - | - | 0.00 |
| CreateCachedProductQuantity | 5.384 ns | 0.0211 ns | 0.0197 ns | 0.86 | 0.01 | - | - | 0.00 |
| CreateScalarPowerQuantity | 13.797 ns | 0.0667 ns | 0.0591 ns | 2.21 | 0.03 | - | - | 0.00 |
| CreateSquarePowerQuantity | 5.432 ns | 0.0944 ns | 0.0883 ns | 0.87 | 0.02 | - | - | 0.00 |
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|------------------------------- |-----------:|----------:|------:|----------:|------------:|
| CreateObject | 6.5121 ns | 0.0446 ns | 1.00 | 24 B | 1.00 |
| CreateStruct | 1.3764 ns | 0.0507 ns | 0.21 | - | 0.00 |
| CreateScalarQuantity | 0.8206 ns | 0.0354 ns | 0.13 | - | 0.00 |
| CreateScalarQuantityWithoutOpt | 3.4004 ns | 0.0235 ns | 0.52 | - | 0.00 |
| CreateQuotientQuantity | 13.1254 ns | 0.0655 ns | 2.02 | - | 0.00 |
| CreateProductQuantity | 15.1995 ns | 0.1573 ns | 2.33 | - | 0.00 |
| CreateCachedProductQuantity | 1.0541 ns | 0.0074 ns | 0.16 | - | 0.00 |
| CreateScalarPowerQuantity | 11.3300 ns | 0.2369 ns | 1.74 | - | 0.00 |
| CreateSquarePowerQuantity | 0.7973 ns | 0.0156 ns | 0.12 | - | 0.00 |
*/
37 changes: 18 additions & 19 deletions source/Quantities.Benchmark/DeserializationBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Quantities.Prefixes;
using Quantities.Prefixes;
using Quantities.Units.Si;
using Quantities.Units.Si.Derived;
using Quantities.Units.Si.Metric;

namespace Quantities.Benchmark;

[MemoryDiagnoser]
[MemoryDiagnoser(displayGenColumns: false)]
public class DeserializationBenchmark
{
private static readonly String triple = Triple().Serialize();
Expand Down Expand Up @@ -34,23 +34,22 @@ public class DeserializationBenchmark
private static (Double value, String prefix, String unit) Triple() => (Math.PI, "K", "m");
}

/*
// * Summary *
/* Summary *

BenchmarkDotNet v0.13.8, Arch Linux
BenchmarkDotNet v0.13.10, Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 7.0.113
[Host] : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.13 (7.0.1323.52501), X64 RyuJIT AVX2


| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|----------------------- |-----------:|---------:|---------:|------:|--------:|-------:|----------:|------------:|
| SystemTriple | 195.6 ns | 1.90 ns | 1.68 ns | 1.00 | 0.00 | 0.0095 | 40 B | 1.00 |
| SystemQuantity | 758.5 ns | 9.67 ns | 9.04 ns | 3.88 | 0.07 | 0.0381 | 160 B | 4.00 |
| PrefixedQuantity | 847.8 ns | 13.04 ns | 11.56 ns | 4.34 | 0.09 | 0.0534 | 224 B | 5.60 |
| FractionalQuantity | 2,164.2 ns | 41.96 ns | 56.02 ns | 11.03 | 0.31 | 0.1755 | 744 B | 18.60 |
| MultiplicativeQuantity | 2,102.1 ns | 14.80 ns | 13.12 ns | 10.75 | 0.10 | 0.1755 | 744 B | 18.60 |
| PowerQuantity | 1,961.4 ns | 8.74 ns | 7.74 ns | 10.03 | 0.11 | 0.1411 | 592 B | 14.80 |
| ScalarPowerQuantity | 934.2 ns | 2.81 ns | 2.63 ns | 4.78 | 0.04 | 0.0553 | 232 B | 5.80 |
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|----------------------- |-----------:|--------:|------:|----------:|------------:|
| SystemTriple | 165.1 ns | 0.26 ns | 1.00 | 40 B | 1.00 |
| SystemQuantity | 573.2 ns | 2.34 ns | 3.47 | 160 B | 4.00 |
| PrefixedQuantity | 698.0 ns | 1.61 ns | 4.23 | 224 B | 5.60 |
| FractionalQuantity | 1,286.4 ns | 1.16 ns | 7.79 | 744 B | 18.60 |
| MultiplicativeQuantity | 1,414.5 ns | 7.17 ns | 8.57 | 744 B | 18.60 |
| PowerQuantity | 1,101.9 ns | 2.16 ns | 6.67 | 592 B | 14.80 |
| ScalarPowerQuantity | 781.6 ns | 2.93 ns | 4.73 | 232 B | 5.80 |
*/
35 changes: 17 additions & 18 deletions source/Quantities.Benchmark/DividingQuantities.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Diagnosers;
using Quantities.Prefixes;
using Quantities.Units.Imperial.Area;
using Quantities.Units.Imperial.Length;
Expand All @@ -8,7 +8,7 @@

namespace Quantities.Benchmark;

[MemoryDiagnoser]
[MemoryDiagnoser(displayGenColumns: false)]
public class DividingQuantities
{
private Volume metricVolume = Volume.Of(3, Cubic(Si<Kilo, Metre>()));
Expand Down Expand Up @@ -41,22 +41,21 @@ public class DividingQuantities
public Double DividePureSi() => this.potential / this.current;
}

/*
// * Summary *
/* Summary *

BenchmarkDotNet v0.13.8, Arch Linux
BenchmarkDotNet v0.13.10, 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 |
|--------------- |----------:|----------:|----------:|------:|----------:|------------:|
| Trivial | 16.753 ns | 0.1041 ns | 0.0974 ns | 1.00 | - | NA |
| DivideSi | 7.011 ns | 0.0439 ns | 0.0389 ns | 0.42 | - | NA |
| DivideImperial | 7.059 ns | 0.0548 ns | 0.0512 ns | 0.42 | - | NA |
| DivideMixed | 7.428 ns | 0.1167 ns | 0.1092 ns | 0.44 | - | NA |
| DivideAliased | 7.463 ns | 0.0436 ns | 0.0408 ns | 0.45 | - | NA |
| DividePureSi | 7.016 ns | 0.1720 ns | 0.2048 ns | 0.42 | - | NA |
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|--------------- |----------:|----------:|------:|----------:|------------:|
| Trivial | 16.228 ns | 0.0854 ns | 1.00 | - | NA |
| DivideSi | 6.308 ns | 0.0385 ns | 0.39 | - | NA |
| DivideImperial | 6.464 ns | 0.0357 ns | 0.40 | - | NA |
| DivideMixed | 6.568 ns | 0.0212 ns | 0.40 | - | NA |
| DivideAliased | 6.337 ns | 0.0351 ns | 0.39 | - | NA |
| DividePureSi | 6.223 ns | 0.0330 ns | 0.38 | - | NA |
*/
Loading