jsPerf如何工作? [英] How does jsPerf work?

查看:198
本文介绍了jsPerf如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我访问了 jsPerf ,现在我想知道......

Today I visited jsPerf and now I am wondering…


  1. 什么是ops / sec?

  2. 它会进行多少次迭代?

  3. 基于什么基础它计算哪个更快?这些计算背后的公式是什么?

示例: http://jsperf.com/concatenation-vs-join

谁能告诉我?

提前致谢。

推荐答案

我写了 Benchmark.js jsPerf 使用。


  1. ops / sec 代表每秒的操作数。
    这是一次测试预计在一秒钟内执行的次数。

  1. "ops/sec" stands for operations per second. That is how many times a test is projected to execute in a second.

重复执行测试,直到达到所需的最短时间为止。获得百分比不确定度,以测量小于或等于 1%。迭代次数将根据环境计时器的分辨率以及测试在最短运行时间内执行的次数而有所不同。我们收集完成的测试运行 5 (可配置),或者至少 5 运行(也可配置),然后对样本执行统计分析。因此,测试可能会重复 100,000 50 ms (大多数环境的最短运行时间) ,然后重复 100 多次 5 秒)。较大的样本量(在此示例中, 100 会导致较小的误差范围

A test is repeatedly executed until it reaches the minimum time needed to get a percentage uncertainty for the measurement of less than or equal to 1%. The number of iterations will vary depending on the resolution of the environment’s timer and how many times a test can execute in the minimum run time. We collect completed test runs for 5 seconds (configurable), or at least 5 runs (also configurable), and then perform statistical analysis on the sample. So, a test may be repeated 100,000 times in 50 ms (the minimum run time for most environments), and then repeated 100 times more (5 seconds). A larger sample size (in this example, 100), leads to a smaller margin of error.

我们的决定是基于哪个测试更快ops / sec也考虑了误差范围。例如,具有较低操作/秒但较高误差范围的测试可能与具有较高操作/秒和较低误差范围的测试在统计上无法区分

We base the decision of which test is faster on more than just ops/sec by also accounting for margin of error. For example, a test with a lower ops/sec but higher margin of error may be statistically indistinguishable from a test with higher ops/sec and lower margin of error.

我们使用 welch t-test ,类似于 SunSpider 使用,但切换到不成对的双样本t检验,等方差(方差非常小)因为welch t-test在较低的ops / sec和较高的ops / sec与较小的差异进行比较时遇到了问题,导致自由度计算小于 1 。我们还在具有类似操作/秒的测试中添加 5.5%允许值,因为实际测试表明相同的测试可以摆动〜 5%从测试到重新测试。 T检验用于检查测试之间的差异是具有统计意义

We used a welch t-test, similar to what SunSpider uses, but switched to an unpaired 2-sample t-test for equal variance (the variance is extremely small) because the welch t-test had problems comparing lower ops/sec and higher ops/sec with small variances which caused the degrees of freedom to be computed as less than 1. We also add a 5.5% allowance on tests with similar ops/sec because real world testing showed that identical tests can swing ~5% from test to re-test. T-tests are used to check that differences between tests are statistically significant.

这篇关于jsPerf如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆