-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify console.timeLog() + clean up timing #138
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ namespace console { // but see namespace object requirements below | |
|
||
// Timing | ||
void time(optional DOMString label = "default"); | ||
void timeLog(optional DOMString label = "default", any... data); | ||
void timeEnd(optional DOMString label = "default"); | ||
}; | ||
</pre> | ||
|
@@ -78,8 +79,7 @@ namespace console { // but see namespace object requirements below | |
|
||
<p class="note"> | ||
It is important that {{console}} is always visible and usable to scripts, even if the developer | ||
console has not been opened or | ||
does not exist. | ||
console has not been opened or does not exist. | ||
</p> | ||
|
||
For historical web-compatibility reasons, the <a>namespace object</a> for {{console}} must have as | ||
|
@@ -234,16 +234,50 @@ Each {{console}} namespace object has an associated <dfn>timer table</dfn>, whic | |
1. Otherwise, [=map/set=] the value of the entry with key |label| in the associated | ||
<a>timer table</a> to the current time. | ||
|
||
<h4 id="timelog" method for="console">timeLog(|label|, ...|data|)</h4> | ||
|
||
1. Let |timerTable| be the associated <a>timer table</a>. | ||
1. Let |startTime| be |timerTable|[|label|]. | ||
1. Let |duration| be a string representing the difference between the current time and | ||
|startTime|, in an implementation-defined format. | ||
1. Let |concat| be the concatenation of |label|, U+003A (:), U+0020 SPACE, and |duration|. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we indicate what the duration represent (milliseconds, seconds, ...) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what I'll do here is move the example in timeEnd up to here since the first instance of time represented in an implementation-defined format should probably do the explaining. Probably don't need to add it again in timeEnd since it's a repeat step and already will have an example here. |
||
1. [=list/prepend|Prepend=] |concat| to |data|. | ||
1. Perform <a abstract-op>Printer</a>("timeLog", data). | ||
|
||
<div class="example" id="timelog-example"> | ||
The |data| parameter in calls to {{console/timeLog()}} is included in the call to | ||
<a abstract-op>Logger</a> to make it easier for users to supply intermediate timer logs with | ||
some extra data throughout the life of a timer. For example: | ||
|
||
<pre><code class="lang-javascript"> | ||
console.time("MyTimer"); | ||
console.timeLog("MyTimer", "Starting application up..."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Replace |
||
// Perhaps some code runs to boostrap a complex app | ||
// ... | ||
console.timeLog("MyTimer", "UI is setup, making API calls now"); | ||
// Perhaps some fetch()'s here filling the app with data | ||
// ... | ||
console.timeLog("MyTimer", "All done!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this case would make sense since |
||
console.timeEnd("MyTimer"); | ||
</code></pre> | ||
</div> | ||
|
||
<h4 id="timeend" oldids="timeend-label,dom-console-timeend" method for="console">timeEnd(|label|)</h4> | ||
|
||
1. Let |startTime| be the result of [=map/getting=] the value of the entry with key |label| in the | ||
associated <a>timer table</a>. | ||
1. Let |timerTable| be the associated <a>timer table</a>. | ||
1. Let |startTime| be |timerTable|[|label|]. | ||
1. [=map/Remove=] |timerTable|[|label|]. | ||
1. Let |duration| be a string representing the difference between the current time and | ||
|startTime|, in an implementation-defined format. | ||
<p class="example" id="duration-string-example">"4650", "4650.69 ms", "5 seconds", and "00:05" | ||
are all reasonable ways of displaying a 4650.69 ms duration.</p> | ||
1. Let |concat| be the concatenation of |label|, U+003A (:), U+0020 SPACE, and |duration|. | ||
1. Perform <a abstract-op>Logger</a>("timeEnd", « |concat| »). | ||
1. Perform <a abstract-op>Printer</a>("timeEnd", « |concat| »). | ||
|
||
<p class="note">See <a href="https://github.com/whatwg/console/issues/134">whatwg/console#134</a> | ||
for plans to make {{console/timeEnd()}} and {{console/timeLog()}} formally report warnings to the | ||
console when a given |label| does not exist in the associated <a>timer table</a>. | ||
</p> | ||
|
||
<h2 id="supporting-ops">Supporting abstract operations</h2> | ||
|
||
|
@@ -394,7 +428,7 @@ their output similarly, in four broad categories. This table summarizes these co | |
<td>log</td> | ||
<td> | ||
{{console/log()}}, {{console/trace()}}, {{console/dir()}}, {{console/dirxml()}}, | ||
{{console/group()}}, {{console/groupCollapsed()}}, {{console/debug()}} | ||
{{console/group()}}, {{console/groupCollapsed()}}, {{console/debug()}}, {{console/timeLog()}} | ||
</td> | ||
<td> | ||
A generic log | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if putting "log" between
time
("start") and "end" might make be nicer?