scientistproject / Scientist.net

A .NET library for carefully refactoring critical paths. It's a port of GitHub's Ruby Scientist library
MIT License
1.46k stars 95 forks source link

Improves performance while timing observerations. #100

Closed joncloud closed 6 years ago

joncloud commented 7 years ago

Reduces operations by calculating duration in line. Removes an allocation per observation.

davezych commented 7 years ago

So I have no problem with this, looks benign enough.

However my only question is why - sure, reducing an allocation is good, but I doubt it really had much of an affect. Did you run into a situation where this was causing harm? Just curious, approved on my end either way.

joncloud commented 7 years ago

I didn't run into a situation where it was causing harm. I ended up writing some code in another application which needed to do timing. I reviewed how ASP.NET Core was doing it, and implemented it very similar to this. I had noticed that we were creating the Stopwatch instance and figured it would be worthwhile to update too.

I also ran some performance testing using BenchmarkDotNet.

davezych commented 7 years ago

Neat 👍

Looks good, :shipit: (cc @Haacked )

haacked commented 6 years ago

Reducing allocations is always a good thing. :smile: I agree that there's probably no specific problem here, but it doesn't hurt to follow patterns the ASP.NET team are doing.