Home  >  Article  >  Web Front-end  >  node.js中的console.timeEnd方法使用说明_node.js

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

WBOY
WBOYOriginal
2016-05-16 16:28:041506browse

方法说明:

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

语法:

复制代码 代码如下:

console.timeEnd(label)

接收参数:

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

例子:

复制代码 代码如下:

console.time('100-elements');
for (var i = 0; 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);
};
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn