From a89eeca59051c5d60e93ab2946dd1c74a7226084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 8 Oct 2015 21:19:34 +0200 Subject: [PATCH] console: rename argument of time and timeEnd Name it timerName instead of label. It is clearer that way and matches the description in the doc. It is also how it's named in MDN. PR-URL: https://github.com/nodejs/node/pull/3166 Reviewed-By: Rich Trott Reviewed-By: Roman Reiss Reviewed-By: Trevor Norris --- doc/api/console.markdown | 8 ++++---- lib/console.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/api/console.markdown b/doc/api/console.markdown index f3a69ce951..6e2de6071e 100644 --- a/doc/api/console.markdown +++ b/doc/api/console.markdown @@ -72,18 +72,18 @@ object. This is useful for inspecting large complicated objects. Defaults to - `colors` - if `true`, then the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see below. -### console.time(label) +### console.time(timerName) Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique name. Use the same name when you call -[`console.timeEnd()`](#console_console_timeend_label) to stop the timer and +[`console.timeEnd()`](#console_console_timeend_timername) to stop the timer and output the elapsed time in milliseconds. Timer durations are accurate to the sub-millisecond. -### console.timeEnd(label) +### console.timeEnd(timerName) Stops a timer that was previously started by calling -[`console.time()`](#console_console_time_label) and prints the result to the +[`console.time()`](#console_console_time_timername) and prints the result to the console. Example: diff --git a/lib/console.js b/lib/console.js index 531a383876..d2b4f3fc5b 100644 --- a/lib/console.js +++ b/lib/console.js @@ -55,19 +55,19 @@ Console.prototype.dir = function(object, options) { }; -Console.prototype.time = function(label) { - this._times.set(label, process.hrtime()); +Console.prototype.time = function(timerName) { + this._times.set(timerName, process.hrtime()); }; -Console.prototype.timeEnd = function(label) { - var time = this._times.get(label); +Console.prototype.timeEnd = function(timerName) { + var time = this._times.get(timerName); if (!time) { - throw new Error('No such label: ' + label); + throw new Error('No such timer name: ' + timerName); } const duration = process.hrtime(time); const ms = duration[0] * 1000 + duration[1] / 1e6; - this.log('%s: %sms', label, ms.toFixed(3)); + this.log('%s: %sms', timerName, ms.toFixed(3)); };