是否有可用于测试移动网络应用程序的性能基准测试工具或最佳实践?
答案 0 :(得分:1)
Google Chrome有一个分析器。这可能会有所帮助,除非你真的在另一个浏览器中寻找瓶颈。
https://developers.google.com/chrome-developer-tools/docs/cpu-profiling
答案 1 :(得分:0)
您可以根据下面的代码行来衡量主要代码块的执行时间,以找到瓶颈。在目标移动设备上使用此类测量运行我的应用程序,然后检查日志文件以查找执行时间,这有助于我大大提高应用程序的性能。
MeasureExecution = {
timers: {},
start: function(name){
MeasureExecution.timers[name] = new Date().getTime();
},
stop: function(name){
console.log("Execution time for '"+name+"'="+Math.abs(MeasureExecution.timers[name] - new Date().getTime())+"ms");
delete MeasureExecution.timers[name];
}
};
MyApp = {
init: function(){
// Do some initialisation stuff
MeasureExecution.start("init");
MyApp.doExpensiveStuff();
MeasureExecution.stop("init");
// Do some asynchronous stuff
for(var i=0; i<10; i++){
MyApp.startAsync(i);
}
},
doExpensiveStuff: function(){
for(var i=0; i<10000; i++){
for(var j=0; j<10000; j++){
}
}
},
startAsync: function(id){
MeasureExecution.start("async-"+id);
window.setTimeout(function(){
MyApp.doAsync(id);
}, Math.floor(Math.random() *100));
},
doAsync: function(id){
MyApp.doExpensiveStuff();
MeasureExecution.stop("async-"+id);
}
};
MyApp.init();