From 6af94831a80c4bcf2fb4940c8d51d2026b585c0e Mon Sep 17 00:00:00 2001 From: Mark Stosberg Date: Mon, 22 Dec 2014 15:40:27 -0500 Subject: [PATCH] doc: document time() and timeEnd() relationship `console.time()` and `console.timeEnd()` are very closely related. It's useful to reference them both from each other. Previously, console.time() did not mention that it needed to be paired with a call to console.timeEnd() to be useful, and timeEnd() also failed to mention that console.time() needed to be called first. References in both directions have been added. PR-URL: https://github.com/iojs/io.js/pull/198 Reviewed-By: Ben Noordhuis --- doc/api/console.markdown | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/api/console.markdown b/doc/api/console.markdown index 46ab65fad36..5ce3418daeb 100644 --- a/doc/api/console.markdown +++ b/doc/api/console.markdown @@ -64,11 +64,19 @@ Defaults to `false`. Colors are customizable, see below. ## console.time(label) -Mark a time. +Used to calculate the duration of a specific operation. To start a timer, call +the `console.time()` method, giving it a name as only parameter. To stop the +timer, and to get the elapsed time in miliseconds, just call the +[`console.timeEnd()`](#console_console_timeend_label) method, again passing the +timer's name as the parameter. ## console.timeEnd(label) -Finish timer, record output. Example: +Stops a timer that was previously started by calling +[`console.time()`](#console_console_time_label) and print the result to the +console. + +Example: console.time('100-elements'); for (var i = 0; i < 100; i++) {