CPU周期,内存使用情况,执行时间等等?
除了感知代码的运行速度之外,是否有一种量化的方法来测试JavaScript的性能?
CPU周期,内存使用情况,执行时间等等?
除了感知代码的运行速度之外,是否有一种量化的方法来测试JavaScript的性能?
当前回答
jsPerf试试。这是一个在线javascript性能测试工具,用于对代码段进行基准测试和比较。我一直在用它。
其他回答
下面是一个用于时间性能的可重用类。示例包含在代码中:
/*
Help track time lapse - tells you the time difference between each "check()" and since the "start()"
*/
var TimeCapture = function () {
var start = new Date().getTime();
var last = start;
var now = start;
this.start = function () {
start = new Date().getTime();
};
this.check = function (message) {
now = (new Date().getTime());
console.log(message, 'START:', now - start, 'LAST:', now - last);
last = now;
};
};
//Example:
var time = new TimeCapture();
//begin tracking time
time.start();
//...do stuff
time.check('say something here')//look at your console for output
//..do more stuff
time.check('say something else')//look at your console for output
//..do more stuff
time.check('say something else one more time')//look at your console for output
你可以使用控制台。firebug中的配置文件
我发现执行时间是最好的衡量标准。
jsPerf试试。这是一个在线javascript性能测试工具,用于对代码段进行基准测试和比较。我一直在用它。
性能测试最近成了一个流行词,但这并不是说性能测试在QA中不是一个重要的过程,甚至在产品发布之后也不是。当我开发应用程序时,我使用了许多不同的工具,其中一些是上面提到的chrome Profiler,我通常会查看一个SaaS或一些开源的东西,我可以开始工作,然后忘记它,直到我收到警告,说有些东西出了问题。
有很多很棒的工具可以帮助您关注性能,而不需要您跳过一些基本的提醒设置。这里有一些我认为值得你自己去看看。
Sematext.com Datadog.com Uptime.com Smartbear.com Solarwinds.com
为了画出更清晰的画面,这里有一个关于如何为react应用程序设置监控的小教程。