這個問題主要是針對教育。我只是感興趣爲什麼。我使用的程序從here但修改了它一點點:爲什麼昂貴的服務器比最便宜的上網本的日期時間精度更差?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
long ticks = DateTime.Now.Ticks;
while(true)
{
if (ticks != DateTime.Now.Ticks)
{
long newTicks = DateTime.Now.Ticks;
Console.WriteLine(newTicks - ticks);
ticks = newTicks;
}
else
{
Console.WriteLine("same");
}
}
}
}
}
結果:
$ 600聯想邊緣11,英特爾奔騰U5400,Windows 7家庭普通
same
same
same
same
same
same
same
10000
same
same
$ 10000 HP DL360p Gen8 2 * Xeon E5-2640,Windows Server 2008 R2
same
same
same
same
same
same
same
156001
same
same
same
same
same
same
same
same
same
same
same
same
因此,便宜筆記本上的DateTime離子時間爲10毫秒,昂貴的服務器硬件的精度爲156毫秒。
爲什麼?我猜可能Windows 7比Windows Server 2008 R2更「精確」,但這只是我的猜測。在這兩臺計算機上最新的.NET框架與所有更新和所有的Windows更新安裝。
有測量時鐘的準確性許多方面,這是不是他們 – 2012-07-21 18:38:53
之一@parapurarajkumar這將是很好,如果你可以擴大該評論與鏈接或其他可能的解決方案。你可能會把它放入一個答案中,並阻礙一些觀點! – Prescott 2012-07-21 18:40:33
http://blogs.msdn。com/b/ericlippert/archive/2010/04/08/precision-and-accuracy-of-datetime.aspx – 2012-07-21 18:43:36