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

Add benchmarks for UnitSystem methods #708

merged 1 commit into from Sep 27, 2019

Conversation

lipchev
Copy link
Collaborator

@lipchev lipchev commented Sep 26, 2019

Added benchmarks for UnitSystem methods (UnitSystem.SI) in order to use as base line for comparison (I see there is a tool for that) with the modifications envisioned in #651

Added benchmarks for UnitSystem methods (UnitSystem.SI)
@lipchev
Copy link
Collaborator Author

lipchev commented Sep 26, 2019

BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.737 (1809/October2018Update/Redstone5)
Intel Core i7-7820HQ CPU 2.90GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.0.100-preview5-011568
[Host] : .NET Core 2.1.11 (CoreCLR 4.6.27617.04, CoreFX 4.6.27617.02), 64bit RyuJIT
DefaultJob : .NET Core 2.1.11 (CoreCLR 4.6.27617.04, CoreFX 4.6.27617.02), 64bit RyuJIT

Method Mean Error StdDev Median Gen 0 Gen 1 Gen 2 Allocated
Constructor 9.043 ns 0.0459 ns 0.0429 ns 9.049 ns - - - -
Constructor_SI 423.813 ns 8.2875 ns 13.1449 ns 415.581 ns 0.0453 - - 192 B
FromMethod 21.048 ns 0.1656 ns 0.1549 ns 21.083 ns - - - -
ToProperty 6.484 ns 0.1154 ns 0.0963 ns 6.452 ns - - - -
As 6.298 ns 0.1402 ns 0.1243 ns 6.336 ns - - - -
As_SI 404.015 ns 6.9181 ns 6.1327 ns 405.770 ns 0.0453 - - 192 B
ToUnit 14.556 ns 0.0547 ns 0.0511 ns 14.561 ns - - - -
ToUnit_SI 418.968 ns 8.6850 ns 11.5942 ns 414.785 ns 0.0453 - - 192 B
ToStringTest 1,769.903 ns 5.8755 ns 5.4959 ns 1,770.698 ns 0.1965 - - 832 B
Parse 45,782.334 ns 913.8546 ns 2,099.7328 ns 45,941.022 ns 10.1929 - - 43000 B
TryParseValid 43,719.197 ns 859.6624 ns 1,736.5605 ns 43,829.068 ns 10.1929 - - 42976 B
TryParseInvalid 43,842.192 ns 87.9830 ns 77.9946 ns 43,860.654 ns 10.1318 - - 42576 B
QuantityFrom 58.498 ns 0.6131 ns 0.5435 ns 58.505 ns 0.0132 - - 56 B
IQuantity_As 13.341 ns 0.2962 ns 0.3955 ns 13.260 ns 0.0057 - - 24 B
IQuantity_As_SI 405.592 ns 3.8216 ns 3.3878 ns 406.020 ns 0.0453 - - 192 B
IQuantity_ToUnit 19.525 ns 0.4049 ns 0.3788 ns 19.683 ns 0.0133 - - 56 B
IQuantity_ToStringTest 1,712.609 ns 11.4083 ns 10.1132 ns 1,712.467 ns 0.1945 - - 832 B

@codecov-io
Copy link

codecov-io commented Sep 26, 2019

Codecov Report

Merging #708 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #708   +/-   ##
=======================================
  Coverage   58.32%   58.32%           
=======================================
  Files         166      166           
  Lines       37811    37811           
=======================================
  Hits        22055    22055           
  Misses      15756    15756

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c73d61...fb46334. Read the comment docs.

@angularsen angularsen merged commit 85a4723 into angularsen:master Sep 27, 2019
@angularsen
Copy link
Owner

Great, thanks!

@lipchev
Copy link
Collaborator Author

lipchev commented Sep 28, 2019

A quick note: the performance of the SI methods tested in this release are actually dependent on the quantity that is tested; here we test Length- which has ~ 30 UnitInfos (meter being in the middle), where for example VolumePerLength has only 3- thus it seems your result may vary (being slightly lower for most other quantities, on average):

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Constructor 12.29 ns 0.2328 ns 0.2286 ns - - - -
Constructor_SI_VolumePerLength 327.59 ns 1.1634 ns 1.0883 ns 0.0453 - - 192 B
Constructor_SI_Length 468.77 ns 10.6604 ns 14.9444 ns 0.0453 - - 192 B

@angularsen
Copy link
Owner

Right. I don't recall the exact implementation for looking up the conversion functions from the top of my head, it has changed a few times lately, but I'm sure it can be improved. Maybe as simple as using a dictionary if we are not already using that.

@angularsen
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants