您的位置:首页 > Web前端 > Node.js

node.js中的console.timeEnd方法使用说明

2014-12-09 00:00 856 查看
方法说明:

完成时间,执行 console.time 到 console.timeEnd 之间所花费的时间。

语法:

console.timeEnd(label)

接收参数:

Label 与开始时间 console.log 的 label 对应

例子:

console.time('100-elements');

for (var i = 0; i < 100; i++) {

  ;

}

console.timeEnd('100-elements');

源码:

Console.prototype.timeEnd = function(label) {

  var time = this._times[label];

  if (!time) {

    throw new Error('No such label: ' + label);

  }

  var duration = Date.now() - time;

  this.log('%s: %dms', label, duration);

};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: