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
"debug style" scopes for enabling timeline demarcation of timing measurements #53
base: master
Are you sure you want to change the base?
Conversation
|
Sidenote: React's similar implementation has an "on/off" via query param toggle which is kinda nice. |
Spying on
Its good that this doesn't cause issues when disabled. Although the fact that people enabling this to get further time information itself skews times is unfortunate. It may be worth investing time in ensuring that overhead is a minimal as we can reasonably provide. |
@stefanpenner here's an example of the perf hit: I asked on twitter and @addyosmani suggested this: https://twitter.com/addyosmani/status/810942392249393152 https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure Which I suspect may help our |
a8030ca
to
783a1e9
Compare
A few comments:
|
Why does this diverge the API? |
@runspired @stefanpenner how often do you think this would work as a build time step? Seems like it might be a 90% solution to be able to only do this against the static portion of a string, but that way we could enable context (nodes) at build-variable cost. thoughts? |
783a1e9
to
5184ad1
Compare
@stefanpenner this is ready for review, I'm not sure what's up with the appveyor build failing though, it's suggesting our babel setup isn't correct. EDIT I take back the drift hypothesis given Travis is green. |
0799ffa
to
d97644d
Compare
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.
this seems to be quite abit of code, we should be careful or separate builds for different use-cases (likely future effort).
@@ -0,0 +1,7 @@ | |||
export default function makeDict() { |
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.
this is no longer needed, new v8 makes this the default for Object.create(null)
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.
👍
High Level
performance.mark
to capture timings when available (instead ofperformance.now
).performance.measure
to push a measurement into the timeline when this API is available.console.time
andconsole.timeEnd
with our existingnow()
to capture timings and push measurements into the timeline whenmark
andmeasure
are not available.Concerns
mark
improves the speed of collecting timingsperformance.measure
is available, but these are off by default to be user enabled, and the active scopes can be controlled.HeimdallTree
enables the different expectations to seamlessly interop (and has test coverage)Discussion
The primary new addition is the
PerformanceMeasure
class.This API is similar to the Performance interface https://developer.mozilla.org/en-US/docs/Web/API/Performance
however, it diverges in a couple of key scenarios detailed below:
To support enabling/disabling timeline measuring by "scope", it introduces a
trace()
method which enhances themark
functionality by expecting more information about the nature of the mark being requested.To support measurements appearing in the timeline for Safari and Node, it additionally falls back to
console.time(<label>)
andconsole.timeEnd(<label>)
. Whereasperformance.measure
uses async marks and can be called after-the-fact to add the annotation to the timeline, the console variant is synchronous and must be called at the same point at which the mark is created. This is another motivation for thetrace
API having extend information about the nature of the mark requested.Additionally,
performance.measure
expects to be given the names of two previously createdmarks
; however,performance.mark
intentionally supports callingmark
with the same name repeatedly. This makes these two APIs at odds. Instead of using the name passed intoheimdall.start()
, we use thetraceId
we generate for that mark to ensure a unique mark name.Usage
On your heimdall instance:
Calls to this method are "additive only" at the moment.
Miscellaneous Questions
id
is currently an index into the events array.traceId
can replaceid
entirely either byHeimdall
generating a similar monotonic ID or by havingHeimdall
'sstart|stop|resume
methods utilize thetraceId
that calling_trace
generates. Either scenario would improve our ability to segment the data, utilize a buffer approach, and stream it if desired.Many thanks to @twokul for pairing with me on the
PerformanceMeasure
class.