我有我的 reduce 方法,我想计算需要多少时间,所以我基本上想做类似的事情:
function(key, values, rereduce) {
var start_time = new Date();
// my calcs here.
var totallength = 0; // this is wrong... any global variables or closure?
var totaltime = 0; // this is wrong... any global variables or closure?
time_calc_took = new Date() - start_time;
totallength += values.length;
totaltime += time_calc_took;
return([totallength, totaltime, someother_results]);
}
然而,由于总长度和总时间不是全局变量,我无法真正衡量我的视图性能,我想知道它在不同的行数上运行需要多少时间。