Is there a high precision timer in .NET at all? I have tested the System.DateTime structure on my Linux machine, and it seems pretty fast to me...unless I am getting to tired and have an error in my code:
Please tell me if you see a logic error. Since I am pretty tired now...
This gives me a resolution from 0.04-0.09ms on my computer, witch is surprisingly good. But I read an article that a MVP wrote, that it seldoms gives you better resolution then 16ms. Something I can't see right now. Is that because it it on Windows is wrapped around timeGetTime or GetTickCount API or what? Can anyone test what they get on their Win machine, and or find the error in my test?Code:long diff = 0; long totdiff = 0; System.DateTime dt1 = System.DateTime.Now; System.DateTime dt2 = System.DateTime.Now; for (int i = 0; i < 10000; i++){ dt1 = System.DateTime.Now; diff = dt1.Ticks - dt2.Ticks; dt2 = dt1; totdiff += diff; //Console.WriteLine("Tid" + i + ": " + diff); } totdiff /= 10000; Console.WriteLine("Total diff: " + totdiff);
- ØØ -




Reply With Quote