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

Please use System.Diagnostics.Stopwatch.GetTimestamp() for high resolution time #223

Open
AceHack opened this issue Jan 3, 2019 · 1 comment

Comments

@AceHack
Copy link

AceHack commented Jan 3, 2019

In some static constructor keep up with the following:

            StartDateTime = DateTime.UtcNow;
            StartTicks = System.Diagnostics.Stopwatch.GetTimestamp();

Then you can calculate the current high precision time using:

            startDateTime.AddTicks(System.Diagnostics.Stopwatch.GetTimestamp() - startTicks)

Thanks.

@AceHack
Copy link
Author

AceHack commented Jan 3, 2019

Then you can check the following to make sure it's high precision time:

            Console.WriteLine(System.Diagnostics.Stopwatch.IsHighResolution);
            Console.WriteLine(System.Diagnostics.Stopwatch.Frequency);

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

1 participant