Skip to content
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
1 change: 1 addition & 0 deletions source/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ indent_size = 2
# C# files
[*.cs]
indent_size = 4
max_line_length = 180
#### Core EditorConfig Options ####

#### .NET Coding Conventions ####
Expand Down
22 changes: 11 additions & 11 deletions source/Atmoos.Quantities.Benchmark/AddingQuantities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ public class AddingQuantities
private Si<Metre> smallTrivial = Si<Metre>.Of(Prefix.Micro, 12);

[Benchmark(Baseline = true)]
public Double Trivial() => this.largeTrivial + this.smallTrivial;
public Si<Metre> Trivial() => this.largeTrivial + this.smallTrivial;

[Benchmark]
public Double AddSi() => this.largeMetric + this.smallMetric;
public Length AddSi() => this.largeMetric + this.smallMetric;

[Benchmark]
public Double AddSiSame() => this.sameMetric + this.largeMetric;
public Length AddSiSame() => this.sameMetric + this.largeMetric;

[Benchmark]
public Double AddImperial() => this.largeImperial + this.smallImperial;
public Length AddImperial() => this.largeImperial + this.smallImperial;

[Benchmark]
public Double AddMixed() => this.smallMetric + this.largeImperial;
public Length AddMixed() => this.smallMetric + this.largeImperial;
}

/* Summary

BenchmarkDotNet v0.15.8, Linux Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Max: 0.40GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
Intel Core i7-8565U CPU 1.80GHz (Max: 3.39GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 10.0.100
[Host] : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|------------ |----------:|----------:|------:|----------:|------------:|
| Trivial | 1.2829 ns | 0.0205 ns | 1.00 | - | NA |
| AddSi | 2.3519 ns | 0.0157 ns | 1.83 | - | NA |
| AddSiSame | 0.7100 ns | 0.0098 ns | 0.55 | - | NA |
| AddImperial | 2.4191 ns | 0.0155 ns | 1.89 | - | NA |
| AddMixed | 2.4079 ns | 0.0126 ns | 1.88 | - | NA |
| Trivial | 1.1845 ns | 0.0304 ns | 1.00 | - | NA |
| AddSi | 2.2187 ns | 0.0091 ns | 1.87 | - | NA |
| AddSiSame | 0.5849 ns | 0.0032 ns | 0.49 | - | NA |
| AddImperial | 2.2336 ns | 0.0090 ns | 1.89 | - | NA |
| AddMixed | 2.1848 ns | 0.0134 ns | 1.85 | - | NA |
*/
22 changes: 11 additions & 11 deletions source/Atmoos.Quantities.Benchmark/ConvertingQuantities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ public class ConvertingQuantities
private static readonly Energy energy = Energy.Of(3, Si<Milli, Watt>().Times(Si<Kilo, Second>()));

[Benchmark(Baseline = true)]
public Double TrivialImplementation() => trivialFoot.To(kiloMetre);
public Si<Metre> TrivialImplementation() => trivialFoot.To(kiloMetre);

[Benchmark]
public Double QuantityImplementation() => foot.To(Si<Kilo, Metre>());
public Length QuantityImplementation() => foot.To(Si<Kilo, Metre>());

[Benchmark]
public Double QuantityToSame() => energy.To(Si<Milli, Watt>().Times(Si<Kilo, Second>()));
public Energy QuantityToSame() => energy.To(Si<Milli, Watt>().Times(Si<Kilo, Second>()));

[Benchmark]
public Double QuantityToVeryDifferent() => energy.To(Si<Kilo, Watt>().Times(Si<Milli, Second>()));
public Energy QuantityToVeryDifferent() => energy.To(Si<Kilo, Watt>().Times(Si<Milli, Second>()));
}

/* Summary

BenchmarkDotNet v0.15.8, Linux Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Max: 0.40GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
Intel Core i7-8565U CPU 1.80GHz (Max: 3.39GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 10.0.100
[Host] : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|------------------------ |----------:|----------:|------:|----------:|------------:|
| TrivialImplementation | 0.4036 ns | 0.0070 ns | 1.00 | - | NA |
| QuantityImplementation | 3.0707 ns | 0.0270 ns | 7.61 | - | NA |
| QuantityToSame | 6.4970 ns | 0.0100 ns | 16.10 | - | NA |
| QuantityToVeryDifferent | 8.3149 ns | 0.0133 ns | 20.61 | - | NA |
| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|------------------------ |-----------:|----------:|------:|----------:|------------:|
| TrivialImplementation | 0.4851 ns | 0.0049 ns | 1.00 | - | NA |
| QuantityImplementation | 2.8680 ns | 0.0113 ns | 5.91 | - | NA |
| QuantityToSame | 7.1614 ns | 0.0594 ns | 14.76 | - | NA |
| QuantityToVeryDifferent | 11.3560 ns | 0.0348 ns | 23.41 | - | NA |
*/
27 changes: 14 additions & 13 deletions source/Atmoos.Quantities.Benchmark/DividingQuantities.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Atmoos.Quantities.Physics;
using Atmoos.Quantities.Prefixes;
using Atmoos.Quantities.Units.Imperial.Area;
using Atmoos.Quantities.Units.Imperial.Length;
Expand All @@ -23,39 +24,39 @@ public class DividingQuantities
private Si<Metre> smallTrivial = Si<Metre>.Of(Prefix.Micro, 12);

[Benchmark(Baseline = true)]
public Double Trivial() => this.largeTrivial / this.smallTrivial;
public Si<Metre> Trivial() => this.largeTrivial / this.smallTrivial;

[Benchmark]
public Double DivideSi() => this.metricVolume / this.metricArea;
public Length DivideSi() => this.metricVolume / this.metricArea;

[Benchmark]
public Double DivideImperial() => this.imperialVolume / this.imperialArea;
public Length DivideImperial() => this.imperialVolume / this.imperialArea;

[Benchmark]
public Double DivideMixed() => this.metricVolume / this.imperialArea;
public Length DivideMixed() => this.metricVolume / this.imperialArea;

[Benchmark]
public Double DivideAliased() => this.metricAcceptedVolume / this.imperialPureArea;
public Length DivideAliased() => this.metricAcceptedVolume / this.imperialPureArea;

[Benchmark]
public Double DividePureSi() => this.potential / this.current;
public ElectricalResistance DividePureSi() => this.potential / this.current;
}

/* Summary

BenchmarkDotNet v0.15.8, Linux Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Max: 0.40GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
Intel Core i7-8565U CPU 1.80GHz (Max: 3.39GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 10.0.100
[Host] : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|--------------- |----------:|----------:|------:|----------:|------------:|
| Trivial | 15.598 ns | 0.0320 ns | 1.00 | - | NA |
| DivideSi | 6.415 ns | 0.0599 ns | 0.41 | - | NA |
| DivideImperial | 7.924 ns | 0.0144 ns | 0.51 | - | NA |
| DivideMixed | 6.477 ns | 0.0104 ns | 0.42 | - | NA |
| DivideAliased | 7.814 ns | 0.0210 ns | 0.50 | - | NA |
| DividePureSi | 7.664 ns | 0.0210 ns | 0.49 | - | NA |
| Trivial | 16.115 ns | 0.0539 ns | 1.00 | - | NA |
| DivideSi | 6.757 ns | 0.0481 ns | 0.42 | - | NA |
| DivideImperial | 6.758 ns | 0.0314 ns | 0.42 | - | NA |
| DivideMixed | 9.767 ns | 0.1089 ns | 0.61 | - | NA |
| DivideAliased | 7.762 ns | 0.0378 ns | 0.48 | - | NA |
| DividePureSi | 6.504 ns | 0.0350 ns | 0.40 | - | NA |
*/
31 changes: 16 additions & 15 deletions source/Atmoos.Quantities.Benchmark/MultiplyingQuantities.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Atmoos.Quantities.Physics;
using Atmoos.Quantities.Prefixes;
using Atmoos.Quantities.Units.Imperial.Length;
using Atmoos.Quantities.Units.Si;
Expand All @@ -22,43 +23,43 @@ public class MultiplyingQuantities
private Si<Metre> smallTrivial = Si<Metre>.Of(Prefix.Micro, 12);

[Benchmark(Baseline = true)]
public Double Trivial() => this.largeTrivial * this.smallTrivial;
public Si<Metre> Trivial() => this.largeTrivial * this.smallTrivial;

[Benchmark]
public Double MultiplySi() => this.largeMetric * this.smallMetric;
public Area MultiplySi() => this.largeMetric * this.smallMetric;

[Benchmark]
public Double MultiplyImperial() => this.largeImperial * this.smallImperial;
public Area MultiplyImperial() => this.largeImperial * this.smallImperial;

[Benchmark]
public Double MultiplyMixed() => this.smallMetric * this.largeImperial;
public Area MultiplyMixed() => this.smallMetric * this.largeImperial;

[Benchmark]
public Double MultiplyPureSi() => this.current * this.resistance;
public ElectricPotential MultiplyPureSi() => this.current * this.resistance;

[Benchmark]
public Double MultiplyPowerQuantity() => this.powerArea * this.largeMetric;
public Volume MultiplyPowerQuantity() => this.powerArea * this.largeMetric;

[Benchmark]
public Double MultiplyAliasQuantity() => this.aliasArea * this.largeMetric;
public Volume MultiplyAliasQuantity() => this.aliasArea * this.largeMetric;
}

/* Summary

BenchmarkDotNet v0.15.8, Linux Arch Linux
Intel Core i7-8565U CPU 1.80GHz (Max: 0.40GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
Intel Core i7-8565U CPU 1.80GHz (Max: 3.39GHz) (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK 10.0.100
[Host] : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.0 (10.0.0, 42.42.42.42424), X64 RyuJIT x86-64-v3


| Method | Mean | Error | Ratio | Allocated | Alloc Ratio |
|---------------------- |----------:|----------:|------:|----------:|------------:|
| Trivial | 15.073 ns | 0.0322 ns | 1.00 | - | NA |
| MultiplySi | 6.743 ns | 0.0425 ns | 0.45 | - | NA |
| MultiplyImperial | 6.141 ns | 0.0156 ns | 0.41 | - | NA |
| MultiplyMixed | 6.627 ns | 0.0292 ns | 0.44 | - | NA |
| MultiplyPureSi | 6.133 ns | 0.0152 ns | 0.41 | - | NA |
| MultiplyPowerQuantity | 6.705 ns | 0.0074 ns | 0.44 | - | NA |
| MultiplyAliasQuantity | 6.737 ns | 0.0376 ns | 0.45 | - | NA |
| Trivial | 15.875 ns | 0.0373 ns | 1.00 | - | NA |
| MultiplySi | 6.506 ns | 0.0614 ns | 0.41 | - | NA |
| MultiplyImperial | 6.128 ns | 0.0345 ns | 0.39 | - | NA |
| MultiplyMixed | 6.235 ns | 0.0233 ns | 0.39 | - | NA |
| MultiplyPureSi | 6.241 ns | 0.0248 ns | 0.39 | - | NA |
| MultiplyPowerQuantity | 6.567 ns | 0.0223 ns | 0.41 | - | NA |
| MultiplyAliasQuantity | 6.581 ns | 0.0181 ns | 0.41 | - | NA |
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Atmoos.Quantities.Dimensions;
using Atmoos.Quantities.Physics;
using Atmoos.Quantities.Prefixes;
using Atmoos.Quantities.Units.Imperial.Length;
using Atmoos.Quantities.Units.Si;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Atmoos.Quantities" Version="2.1.1" />
<ProjectReference Include="../../Atmoos.Quantities/Atmoos.Quantities.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void HertzDeserializesCorrectly()
public void InverseTimeDeserializesCorrectly()
{
Time time = Time.Of(0.5, Si<Second>());
Frequency frequency = 2 / time;
Frequency frequency = 2d / time;

String actual = frequency.Serialize(options);

Expand All @@ -51,7 +51,7 @@ public void InverseTimeDeserializesCorrectly()
public void InverseTimeSerializesRoundRobin()
{
Time time = Time.Of(1, Si<Second>());
Frequency expected = 6 / time;
Frequency expected = 6d / time;

Frequency roundRobin = expected.SerializeRoundRobin();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global using Atmoos.Quantities.Prefixes;
global using Atmoos.Quantities.Physics;
global using Atmoos.Quantities.Prefixes;
global using Atmoos.Quantities.Units.Si;
global using Atmoos.Quantities.Units.Si.Derived;
global using Atmoos.Quantities.Units.Si.Metric;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atmoos.Quantities" Version="2.1.1" />
<ProjectReference Include="../../Atmoos.Quantities/Atmoos.Quantities.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions source/Atmoos.Quantities.Test/ExtensionsTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Atmoos.Quantities.Physics;
using Atmoos.Quantities.Units.Si.Metric;

using static System.Math;
Expand Down
Loading
Loading