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

Adding benchmark project #637

Merged
merged 5 commits into from
Jul 17, 2019
Merged

Conversation

tmilnthorp
Copy link
Collaborator

Wanted to draft a first shot at #623

@tmilnthorp
Copy link
Collaborator Author

tmilnthorp commented Mar 6, 2019

Pretty cool! My results:

BenchmarkDotNet=v0.11.4, OS=Windows 10.0.14393.2791 (1607/AnniversaryUpdate/Redstone1)
Intel Xeon CPU E5-2687W v3 3.10GHz, 2 CPU, 20 logical and 20 physical cores
Frequency=3020348 Hz, Resolution=331.0877 ns, Timer=TSC
  [Host]     : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3324.0
  DefaultJob : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3324.0

Method Mean Error StdDev Median Gen 0/1k Op Gen 1/1k Op Gen 2/1k Op Allocated Memory/Op
Constructor 13.191 ns 0.0175 ns 0.0155 ns 13.186 ns - - - -
FromMethod 45.869 ns 0.0196 ns 0.0174 ns 45.864 ns - - - -
ToProperty 6.811 ns 0.0066 ns 0.0058 ns 6.808 ns - - - -
As 6.817 ns 0.0066 ns 0.0061 ns 6.818 ns - - - -
ToUnit 19.746 ns 0.0053 ns 0.0047 ns 19.745 ns - - - -
ToStringTest 1,914.617 ns 2.7741 ns 2.5949 ns 1,914.358 ns 0.1297 - - 688 B
Parse 43,058.513 ns 231.7625 ns 205.4514 ns 42,972.873 ns 4.5776 0.0610 - 24185 B
TryParseValid 42,474.160 ns 371.5787 ns 347.5750 ns 42,294.248 ns 4.5776 0.0610 - 24173 B
TryParseInvalid 43,776.511 ns 216.8559 ns 202.8471 ns 43,746.717 ns 4.5166 0.0610 - 23868 B
QuantityFrom 120.274 ns 1.0679 ns 0.9989 ns 120.602 ns 0.0067 - - 36 B
IQuantity_As 11.970 ns 0.1109 ns 0.1038 ns 11.974 ns 0.0023 - - 12 B
IQuantity_ToUnit 28.815 ns 0.0355 ns 0.0315 ns 28.824 ns 0.0069 - - 36 B
IQuantity_ToStringTest 2,089.823 ns 49.9839 ns 147.3788 ns 2,190.272 ns 0.1297 - - 688 B

@tmilnthorp
Copy link
Collaborator Author

I switched over everything to class and here are the results on the same machine:

BenchmarkDotNet=v0.11.4, OS=Windows 10.0.14393.2791 (1607/AnniversaryUpdate/Redstone1)
Intel Xeon CPU E5-2687W v3 3.10GHz, 2 CPU, 20 logical and 20 physical cores
Frequency=3020348 Hz, Resolution=331.0877 ns, Timer=TSC
  [Host]     : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3324.0
  DefaultJob : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3324.0

Method Mean Error StdDev Median Gen 0/1k Op Gen 1/1k Op Gen 2/1k Op Allocated Memory/Op
Constructor 13.667 ns 0.0697 ns 0.0618 ns 13.659 ns 0.0046 - - 24 B
FromMethod 48.528 ns 0.1178 ns 0.1102 ns 48.500 ns 0.0045 - - 24 B
ToProperty 6.768 ns 0.0223 ns 0.0208 ns 6.768 ns - - - -
As 6.765 ns 0.0171 ns 0.0152 ns 6.765 ns - - - -
ToUnit 22.419 ns 0.0531 ns 0.0415 ns 22.414 ns 0.0046 - - 24 B
ToStringTest 1,852.535 ns 4.2119 ns 3.5171 ns 1,852.616 ns 0.1259 - - 664 B
Parse 42,695.622 ns 139.4434 ns 123.6129 ns 42,664.711 ns 4.5776 0.0610 - 24209 B
TryParseValid 42,701.804 ns 390.5792 ns 365.3481 ns 42,550.505 ns 4.5776 0.0610 - 24197 B
TryParseInvalid 43,811.580 ns 236.0834 ns 220.8326 ns 43,769.209 ns 4.5166 0.0610 - 23868 B
QuantityFrom 117.510 ns 0.2298 ns 0.2150 ns 117.483 ns 0.0067 - - 36 B
IQuantity_As 56.601 ns 50.4925 ns 58.1473 ns 30.088 ns - - - 12 B
IQuantity_ToUnit 28.047 ns 0.0989 ns 0.0925 ns 28.054 ns 0.0069 - - 36 B
IQuantity_ToStringTest 1,913.900 ns 33.9251 ns 31.7336 ns 1,899.572 ns 0.1259 - - 664 B

@angularsen
Copy link
Owner

Very neat, so from a first glance, looks pretty darn similar to me?

@tmilnthorp
Copy link
Collaborator Author

Nothing too horrible. IQuantity_As is the only standout.

That said, these are only testing existing created quantities (minus the constructor). I will add more tests that actually create and then do something with it. I think you might see differences there (due to boxing and unboxing or lack there of).

@angularsen
Copy link
Owner

I'm inclined to merge this @tmilnthorp , we can always improve in further PRs. It's easier to test it locally and play with it when merged. Agree?

@tmilnthorp
Copy link
Collaborator Author

Sounds good to me!

@angularsen angularsen merged commit 2295299 into angularsen:master Jul 17, 2019
@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.

2 participants