From f3c397cd212dfa372e3a23012a62aae62b36011e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 13 Jun 2018 15:30:21 +0200 Subject: [PATCH] console: implement timeLog method Refs: https://github.com/whatwg/console/pull/138 PR-URL: https://github.com/nodejs/node/pull/21312 Reviewed-By: Colin Ihrig Reviewed-By: Gus Caplan Reviewed-By: Anatoli Papirovski Reviewed-By: Weijia Wang Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- doc/api/console.md | 19 ++++++++++++++++ lib/console.js | 28 +++++++++++++++++++----- test/parallel/test-console.js | 41 +++++++++++++++++++++++++++-------- 3 files changed, 73 insertions(+), 15 deletions(-) diff --git a/doc/api/console.md b/doc/api/console.md index 6c63a4ffb56656..95801c31fed63c 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -413,6 +413,25 @@ console.timeEnd('100-elements'); // prints 100-elements: 225.438ms ``` +### console.timeLog([label][, ...data]) + +* `label` {string} **Default:** `'default'` +* `...data` {any} + +For a timer that was previously started by calling [`console.time()`][], prints +the elapsed time and other `data` arguments to `stdout`: + +```js +console.time('process'); +const value = expensiveProcess1(); // Returns 42 +console.timeLog('process', value); +// Prints "process: 365.227ms 42". +doExpensiveProcess2(value); +console.timeEnd('process'); +``` + ### console.trace([message][, ...args])