<div dir="ltr"><div dir="ltr">On Wed, Apr 8, 2020 at 6:35 PM Tom Ritter <<a href="mailto:tom@mozilla.com">tom@mozilla.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm pretty sure that if you're not in the System Principal; your<br>
timestamps from the performance object are going to be clamped to 1ms<br>
resolution (and potentially jittered forward....)<br></blockquote><div><br></div><div>ChromeUtils is only available to System Principal code.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I'm not sure in what context this will be used; or if there's<br>
something that would prevent this timing behavior from taking effect;<br>
but it would be worth confirming and documenting I think.<br>
<br>
-tom<br>
<br>
On Tue, Apr 7, 2020 at 8:22 AM Florian Quèze <<a href="mailto:florian@queze.net" target="_blank">florian@queze.net</a>> wrote:<br>
><br>
> I recently landed a new scriptable API to add profiler markers: ChromeUtils.addProfilerMarker.<br>
> This makes it possible for chrome privileged JS code to insert profiler markers that (optionally) have a duration and an associated text.<br>
><br>
> Examples:<br>
><br>
> Adding a marker without duration:<br>
> ChromeUtils.addProfilerMarker("markerName");<br>
> Adding a marker showing the time it took to do something:<br>
> let startTime = performance.now();<br>
> /* do stuff */<br>
> ChromeUtils.addProfilerMarker("markerName", startTime);<br>
> The performance object is available in windows and workers. In JS modules, use Cu.now() instead of performance.now().<br>
> Adding a marker with a duration and an associated extra string:<br>
> ChromeUtils.addProfilerMarker("markerName", startTime, "marker text");<br>
><br>
><br>
> Hopefully, this should make it easier to show clearly in the profiler what our JS code is doing. The first use I made of this was to show the OS.File operations that are done asynchronously (example profile: <a href="https://perfht.ml/2RhAKXF" rel="noreferrer" target="_blank">https://perfht.ml/2RhAKXF</a>).<br>
><br>
> Scriptable marker APIs that already existed:<br>
><br>
> Adding a marker from XPCOM-enabled contexts:<br>
> if (Services.profiler) {<br>
>   Services.profiler.addMarker("markerName");<br>
> }<br>
> The null check was required to avoid exceptions on tier3 platforms that don't implement the profiler service.<br>
> We will probably want to deprecate this API and migrate all existing callers.<br>
> Adding a 'UserTiming' marker with a duration in a window or worker:<br>
> performance.mark("markName");<br>
> /* do stuff */<br>
> performance.measure("marker text", "markName");<br>
> This will add a marker named UserTiming with the "marker text" associated text, and the duration between the performance.mark and the performance.measure calls. However, the performance.measure implementation is slow enough that it adds significant overhead if called frequently.<br>
> This API will remain available, but should be avoided for chrome privileged code.<br>
><br>
><br>
> --<br>
> Florian Quèze<br>
> _______________________________________________<br>
> firefox-dev mailing list<br>
> <a href="mailto:firefox-dev@mozilla.org" target="_blank">firefox-dev@mozilla.org</a><br>
> <a href="https://mail.mozilla.org/listinfo/firefox-dev" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/firefox-dev</a><br>
_______________________________________________<br>
dev-platform mailing list<br>
<a href="mailto:dev-platform@lists.mozilla.org" target="_blank">dev-platform@lists.mozilla.org</a><br>
<a href="https://lists.mozilla.org/listinfo/dev-platform" rel="noreferrer" target="_blank">https://lists.mozilla.org/listinfo/dev-platform</a><br>
</blockquote></div></div>