Skip to content

Instantly share code, notes, and snippets.

@MarkPflug
Created August 25, 2017 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkPflug/0a58b5cb44647f348f97c5c4b37f7db9 to your computer and use it in GitHub Desktop.
Save MarkPflug/0a58b5cb44647f348f97c5c4b37f7db9 to your computer and use it in GitHub Desktop.
Test DateTime.UtcNow resolution
using System;
class Program
{
static void Main(string[] args)
{
int total = 0;
int count = 0;
while (true) {
count++;
var start = DateTime.UtcNow;
for (int i = 0; ; i++) {
var now = DateTime.UtcNow;
if (now > start) {
total += i;
var avg = total / count;
Console.WriteLine(avg + " " + (now - start).ToString());
start = now;
break;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment