RESOLVED WONTFIX 72219
Web Inspector: making console.timeEnd return a value
https://bugs.webkit.org/show_bug.cgi?id=72219
Summary Web Inspector: making console.timeEnd return a value
Pablo Garaizar
Reported 2011-11-12 15:37:56 PST
Since 2008, Firebug's console.timeEnd returns its value to JavaScript (http://code.google.com/p/fbug/issues/detail?id=42). IMHO this is pretty useful because allows JavaScript programmers to make decisions based on actual performance tested by an external component (supposedly not affected by JavaScript timers' limitations). Technically, seems to be a simple fix, just return "elapsed" variable value instead of void.
Attachments
Pavel Feldman
Comment 1 2011-11-13 06:04:58 PST
(In reply to comment #0) > Since 2008, Firebug's console.timeEnd returns its value to JavaScript (http://code.google.com/p/fbug/issues/detail?id=42). > > IMHO this is pretty useful because allows JavaScript programmers to make decisions based on actual performance tested by an external component (supposedly not affected by JavaScript timers' limitations). > > Technically, seems to be a simple fix, just return "elapsed" variable value instead of void. I don't think console methods should return values to the web. We have a single exception to that (console.profiles) that we'd like to get rid of. We also are not recommending using console.* in the production code since it might lead to the performance regressions. APIs like window.performance are serving this need instead. Why new Date() is not working for you? What do you mean by "JavaScript timers' limitation"? (marking as won't fix for now)
Pablo Garaizar
Comment 2 2011-11-13 07:09:31 PST
By "JavaScript timer's limitations" I meant "JavaScript's timing functions limitations": http://ejohn.org/blog/accuracy-of-javascript-time/ (sorry for the confusion between timers and timing functions). Regarding new Date(), its resolution will never be higher than 1 ms (as ECMAScript standards defined it), and their accuracy and precision may vary depending on the underlying OS. Nevertheless, I undestand the reasons to close this bug report (console Object's aim is debugging, not production code), but I would really appreciate any clue about WebKit's compliance of the new W3C User Timing API. Thank you for your time ;-)
Tony Gentilcore
Comment 3 2011-11-14 02:17:05 PST
+1 to pfeldman's comment. We'll likely add something simple like performance.now() which exposes a high res, monotonically increasing time. You can follow that here: https://bugs.webkit.org/show_bug.cgi?id=66684
Pablo Garaizar
Comment 4 2011-11-14 04:21:09 PST
That's really cool! Thank you very much, Pavel and Tony ;-)
Note You need to log in before you can comment on or make changes to this bug.