为什么我的Stopwatch

为什么我的Stopwatch

本文介绍了为什么我的Stopwatch.Frequency这么低?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Debug.WriteLine("Timer is high-resolution: {0}", Stopwatch.IsHighResolution); Debug.WriteLine("Timer frequency: {0}", Stopwatch.Frequency); 结果:Result: Timer is high-resolution: True Timer frequency: 2597705 这文章(2005年!)提到的3579545频率,万只以上矿。 这的博客文章中提到的一个3325040000的频率,这是疯了。This article (from 2005!) mentions a Frequency of 3579545, a million more than mine. This blog post mentions a Frequency of 3,325,040,000, which is insane.为什么我的频率这么多相对较低?我是酷睿i7 920的机器上,所以它不应该是更快?Why is my Frequency so much comparatively lower? I'm on an i7 920 machine, so shouldn't it be faster?推荐答案 3579545是一个神奇的数字。这就是将其除以3,并将其供入在原始的IBM PC的8053定时器芯片之前在赫兹的频率。不被意外选择奇数寻找数,它是用于在NTSC电视系统的色同步信号的频率在美国和日本。 IBM的工程师们正在寻找一种廉价的水晶来实现振荡器,没有什么比在每一个电视机中使用的更便宜。3,579,545 is the magic number. That's the frequency in Hertz before dividing it by 3 and feeding it into the 8053 timer chip in the original IBM PC. The odd looking number wasn't chosen by accident, it is the frequency of the color burst signal in the NTSC TV system used in the US and Japan. The IBM engineers were looking for a cheap crystal to implement the oscillator, nothing was cheaper than the one used in every TV set.在IBM克隆成为广泛使用,它是仍然是重要的为他们的设计人员选择相同的频率。很多MS-DOS软件依赖于定时器这样的速度滴答作响。直接寻址的芯片是共同犯罪。Once IBM clones became widely available, it was still important for their designers to choose the same frequency. A lot of MS-DOS software relied on the timer ticking at that rate. Directly addressing the chip was a common crime.这更换一次的Windows苏醒过来。 2的Windows的版本是虚拟化的定时器芯片的第一个。换句话说,软件不允许直接解决定时器芯片了。所述处理器被配置为在保护模式运行,并拦截要使用I / O指令的尝试。正在运行的内核代码,而不是,允许指令的返回值被伪造。这是现在可以在使用没有他们踩着对方的脚趾计时器多个程序。一个重要的第一步,打破了如何在硬件实际执行的依赖。That changed once Windows came around. A version of Windows 2 was the first one to virtualize the timer chip. In other words, software wasn't allowed to directly address the timer chip anymore. The processor was configured to run in protected mode and intercepted the attempt to use the I/O instruction. Running kernel code instead, allowing the return value of the instruction to be faked. It was now possible to have multiple programs using the timer without them stepping on each other's toes. An important first step to break the dependency on how the hardware is actually implemented. Win32的API(的Windows NT 3.1和Windows 95)正式进入定时器的API ,QueryPerformanceCounter的()和QueryPerformanceFrequency()。内核级组件,硬件适配层,允许BIOS传递频率。现在,它的硬件设计要真正下降的确切频率的依赖是可能的。那花了很长的时间顺便说一句,2000年绝大多数机器仍然有传统的利率各地。The Win32 API (Windows NT 3.1 and Windows 95) formalized access to the timer with an API, QueryPerformanceCounter() and QueryPerformanceFrequency(). A kernel level component, the Hardware Adaption Layer, allows the BIOS to pass that frequency. Now it was possible for the hardware designers to really drop the dependency on the exact frequency. That took a long time btw, around 2000 the vast majority of machines still had the legacy rate.但是,永无止境的追求,以削减电脑的设计成本,杜绝到这一点。如今,硬件设计只是挑选恰好是在芯片组现成的任何频率。 3325040000将是这样一个数目,它是最有可能的CPU时钟频率。这样高的频率是常见的廉价的设计,特别是有一个AMD核心的人。您的号码是很不寻常,一些胜算你的机器不便宜。而定时器是很多更准确,CPU时钟具有典型的电子元件容差。But the never-ending quest to cut costs in PC design put an end to that. Nowadays, the hardware designer just picks any frequency that happens to be readily available in the chipset. 3,325,040,000 would be such a number, it is most probably the CPU clock rate. High frequencies like that are common in cheap designs, especially the ones that have an AMD core. Your number is pretty unusual, some odds that your machine wasn't cheap. And that the timer is a lot more accurate, CPU clocks have typical electronic component tolerances. 这篇关于为什么我的Stopwatch.Frequency这么低?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-05 17:20