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

Add benchmarks for UnitSystem methods #708

Merged
merged 1 commit into from
Sep 27, 2019
Merged
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
12 changes: 12 additions & 0 deletions UnitsNet.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class UnitsNetBenchmarks
[Benchmark]
public Length Constructor() => new Length(3.0, LengthUnit.Meter);

[Benchmark]
public Length Constructor_SI() => new Length(3.0, UnitSystem.SI);

[Benchmark]
public Length FromMethod() => Length.FromMeters(3.0);

Expand All @@ -22,9 +25,15 @@ public class UnitsNetBenchmarks
[Benchmark]
public double As() => length.As(LengthUnit.Centimeter);

[Benchmark]
public double As_SI() => length.As(UnitSystem.SI);

[Benchmark]
public Length ToUnit() => length.ToUnit(LengthUnit.Centimeter);

[Benchmark]
public Length ToUnit_SI() => length.ToUnit(UnitSystem.SI);

[Benchmark]
public string ToStringTest() => length.ToString();

Expand All @@ -43,6 +52,9 @@ public class UnitsNetBenchmarks
[Benchmark]
public double IQuantity_As() => lengthIQuantity.As(LengthUnit.Centimeter);

[Benchmark]
public double IQuantity_As_SI() => lengthIQuantity.As(UnitSystem.SI);

[Benchmark]
public IQuantity IQuantity_ToUnit() => lengthIQuantity.ToUnit(LengthUnit.Centimeter);

Expand Down