Use instructions for the console.timeend method in node.js

  • 2020-03-30 04:33:40
  • OfStack

Method description:

Completion time, the time taken to execute the time between console.time and console.timeend.

Grammar:


console.timeEnd(label)

Receiving parameters:

Label                        Corresponds to the label of the start time console.log

Example:


console.time('100-elements');
for (var i = 0; i < 100; i++) {
  ;
}
console.timeEnd('100-elements');

Source:


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);
};


Related articles: