如何解决测试了来自 jsforcats.com 的代码片段 Firefox 中的执行速度似乎很慢为什么?
Chrome 与 Firefox。当前版本。在关闭附加组件的情况下进行测试。也刷新了 Firefox。
function measureLoopSpeed() {
var count = 0
function addOne() { count = count + 1 }
// Date.Now() returns a big number representing the number of
// milliseconds that have elapsed since Jan 01 1970
var Now = Date.Now()
// Loop until Date.Now() is 1000 milliseconds (1 second) or more into
// the future from when we started looping. On each loop,call addOne
while (Date.Now() - Now < 1000) addOne()
// Finally it has been >= 1000ms,so let's print out our total count
console.log(count)
}
undefined
//On Firefox console
measureLoopSpeed()
4227461 debugger eval code:14:11
undefined
measureLoopSpeed()
4103189 debugger eval code:14:11
undefined
//On Chrome console
undefined
measureLoopSpeed()
11193127
undefined
measureLoopSpeed()
11153367
undefined
measureLoopSpeed()
11159575
*** 1 秒内完成的总任务甚至比不上 chrome 1 秒内完成的任务。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。