-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add console.timeStamp()
to the specification
#236
base: main
Are you sure you want to change the base?
Conversation
This adds a minimal (vague) definition for the `timeStamp()` method, based on its current behavior across Chromium, Firefox, and Safari, and the MDN documentation[^1]. [^1]: https://developer.mozilla.org/en-US/docs/Web/API/console/timestamp_static Ref: whatwg#140
@domfarolino Let's get the ball rolling here. 💪 @and-oli Please loop in your contacts with other browser vendors here. |
Hmm, it looks like you removed this line about tests from the pull request template? Can you add that back and maybe write some tests for this API? You can follow the pattern in https://github.com/web-platform-tests/wpt/tree/master/console. Note the state of testing is a little sad at this point, since these are basically just manual tests :( |
@@ -274,6 +275,12 @@ for plans to make {{console/timeEnd()}} and {{console/timeLog()}} formally repor | |||
console when a given |label| does not exist in the associated <a>timer table</a>. | |||
</p> | |||
|
|||
<h4 id="timestamp" oldids="timestamp-label,dom-console-timestamp" method for="console">timeStamp(|label|)</h4> |
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.
Maybe this should go in its own section about performance APIs? I guess this is kind of time related, but the existing timing APIs all have to do with keeping track of literal time stamps that get printed for the developer, where as timeStamp()
seems to not interact with that timer table at all, and be more focused on interacting with a performance console.
This sounds very similar to console.markTimeline()
actually. Am I correct in thinking it does not deal with actual raw times or timestamps at all?
(Also this is separate, and maybe I am dumb, but can you show me where the marked point actually shows up in the Performance panel's UI, when this API is called? I can't seem to find it when I call the API)
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.
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.
and yeah at least in Chrome, you are right about timeStamp
being independent from the other timing APIs in console
. There, it simply adds an entry to the data buffer of the performance panel (a trace event)
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.
Got it, can you confirm whether or not other browsers behave the same (or at least are as distinct from the other timing APIs as in Chrome)? That will help inform the tests we'll need for this I think.
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.
According to MDN, console.timeStamp()
is solely intended for the purpose of adding data to performance traces, and from my tests with Firefox, that's exactly what happens there.
@and-oli can you confirm for Safari?
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.
@domfarolino Let me know if you want me to put this into a separate section on Performance APIs.
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.
Friendly ping.
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.
Sorry for the delay. Safari also uses console.timeStamp solely to add markers to the Timelines tab: see docs
@@ -66,6 +66,7 @@ namespace console { // but see namespace object requirements below | |||
undefined time(optional DOMString label = "default"); | |||
undefined timeLog(optional DOMString label = "default", any... data); | |||
undefined timeEnd(optional DOMString label = "default"); | |||
undefined timeStamp(optional DOMString label = "default"); |
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.
im not sure exactly the behavior of Chrome/Firefox/etc., but at least in WebKit there is no = "default"
value (i.e. calling console.timeStamp()
will show "Timestamp" in the UI)
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.
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.
Yes, I just fixed V8 last week to have the = "default"
value for all console.time*()
APIs, including console.timeStamp()
. Maybe we can update JSC as well to have consistency.
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 kinda prefer it showing "Timestamp" in the UI, but i dont feel too strongly about it
we could always have the API use = "default"
and then in the UI check if === "default"
and if so show "Timestamp"
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.
Ok, so we can stick to = "default"
for consistency here?
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.
we could always have the API use = "default" and then in the UI check if === "default" and if so show "Timestamp"
This seems a little funky, especially since Safari treats console.timeStamp()
differently from console.timeStamp("default")
—the former defaults to "TimeStamp" and the latter prints "default". Whereas Chrome shows "TimeStamp: default" for both. I think it makes more sense to stick with = "default"
personally. Do you think Safari's inspector would be willing to budge on this @dcrousso ?
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.
like i mentioned, im not a huge fan of showing "default" in the UI as i think it's not super clear (especially when compared to showing "Timestamp"), but Web Inspector certainly can adopt the behavior of DOMString label = "default"
and then have the UI adjust based on whether a value was actually provided
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.
So that means we are good to go with this?
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.
Web Inspector could also unconditionally show “Timestamp: <label-which-defaults-to-‘default’>” to do what chrome does. Either way I agree this isn’t a big deal.
@bmeurer it would be nice to know what Firefox does here (see #236 (comment)) but I think we’re probably good.
Beyond testing that the function exists on the |
@domfarolino any thoughts here? |
Sadly I don't think we can do much more than add a few manual tests to WPT, and do whatever vendor-specific testing you can do. I think this PR is good to go % https://github.com/whatwg/console/pull/236/files#r1676151812. @bmeurer does Firefox match Chrome in this case? (I couldn't find where Firefox puts timeStamp() marks on its performance timeline). If it does match Chrome, we can just land this since it would match 2/3 implementations without strong objections from another. |
This adds a minimal (vague) definition for the
timeStamp()
method, based on its current behavior across Chromium, Firefox, and Safari, and the MDN documentation1.Ref: #140
Preview | Diff
Footnotes
https://developer.mozilla.org/en-US/docs/Web/API/console/timestamp_static ↩