在过去的几个月里,我一直在运行一个我用 C# 编写的处理器密集型程序,它被称为 Zeros6。
到目前为止,大约经过的时间为 157 天,总处理器时间为 1,217 天。【电脑部分细节:Intel Core i7 2600 / 3.4 GHz / 4 cores + hyperthreading -> 8个处理器。】
我使用 Visual Studio Express 2010 和 .NET Framework 的第 4 版(我认为)编写了该程序。
不管怎样,今天我决定安装 Visual Studio Express 2012。安装程序安装了 .NET Framework 4.5 版,然后请求重新启动以继续安装。我停止了 Zeros6 程序并确定了重新启动。重启后 Zeros6 像往常一样自动重启,Visual Studio 安装继续并很快完成。然后我震惊地发现 Zeros6 的运行速度比平时快得多。通常相当稳定在 5.5(每位数皮秒)的速度指标已降至 2.0 - 我从未见过低于 5.34。然后我停止并启动了几次程序,然后再次重新启动计算机,但速度继续提高。如果我们称旧速度为 100%,则新速度为 275%!
我很想知道发生了什么。
一些声明...
uint[] digits;
uint startI;
uint stopI;
public static readonly int bigPowerIncrement = 34;
public static readonly uint myBase = 1000000000;
所有 8 个处理器大部分时间都在做这件事……
{
ulong carry = 0;
unchecked
{
for (uint i = startI; i < stopI; i++)
{
ulong m = ((ulong)digits[i] << bigPowerIncrement) | carry;
carry = m/myBase;
if ((digits[i] = (uint)(m - myBase*carry)) < 1000000)
{ // do this about one time in 1000...
h.specials[h.specialCount++] = i;
}
} // i loop
} // unchecked
h.carry = carry;
}