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

Consider using ValueStopWatch #575

Open
GeertvanHorrik opened this issue Dec 13, 2023 · 3 comments
Open

Consider using ValueStopWatch #575

GeertvanHorrik opened this issue Dec 13, 2023 · 3 comments

Comments

@GeertvanHorrik
Copy link
Member

Source code is available here:

https://github.com/dotnet/aspnetcore/blob/main/src/Shared/ValueStopwatch/ValueStopwatch.cs

This fody addon could check for the availability of the ValueStopwatch. If it exists, use it instead of Stopwatch.

Happy to PR if this is considered a good idea.

@ltrzesniewski
Copy link
Member

I suppose you'd like to get rid of the allocation? I'd just use Stopwatch.GetTimestamp() and compare the ticks at the end - basically what ValueStopwatch does. Also, ValueStopwatch is internal.

@GeertvanHorrik
Copy link
Member Author

Interesting comment, great observations. I can refactor so it replaces the StartNew by getting the timestamp and calculate the difference manually. Only thing to take into account is to convert the ticks to timespan, but that can be a 1-time static thing.

@GeertvanHorrik
Copy link
Member Author

I just cloned the repository, and noticed that @SimonCropp already started a branch for this earlier this year. Not sure why it was finished, but happy to finalize the branch if needed.

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

No branches or pull requests

2 participants