Skip to content

Commit

Permalink
Add msFirstPaint time to nt_first_paint
Browse files Browse the repository at this point in the history
We now also collect first paint time on IE9 and above.  However, note
the inconsistency between IE and Chrome.  IE reports first paint time in
milliseconds since the epoch.  This is consistent with all the other
navtiming timers.  Chrome reports it in seconds.microseconds, which is
inconsistent.

Receivers will have to determine if this was in seconds or in
milliseconds and convert accordingly.  Since data range is very
different, this should not be a problem.
  • Loading branch information
bluesmoon committed Dec 11, 2012
1 parent 3443afc commit ab63b25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/navtiming.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h2 id="beacon">Beacon Parameters</h2>
<tr><td><code>nt_unload_end</code></td><td><code>window.performance.timing.unloadEventEnd</code></td></tr> <tr><td><code>nt_unload_end</code></td><td><code>window.performance.timing.unloadEventEnd</code></td></tr>
<tr><td><code>nt_ssl_st</code></td><td><strong>[optional]</strong> <code>window.performance.secureConnectionStart</code></td></tr> <tr><td><code>nt_ssl_st</code></td><td><strong>[optional]</strong> <code>window.performance.secureConnectionStart</code></td></tr>
<tr><td><code>nt_spdy</code></td><td><strong>[optional]</strong> 1 if page was loaded over SPDY, 0 otherwise</td></tr> <tr><td><code>nt_spdy</code></td><td><strong>[optional]</strong> 1 if page was loaded over SPDY, 0 otherwise</td></tr>
<tr><td><code>nt_first_paint</code></td><td><strong>[optional]</strong> The time in <code>seconds.microseconds</code> when the first paint happened. Note, you will need to multiply this number by 1000 to compare it to the others.</td></tr> <tr><td><code>nt_first_paint</code></td><td><strong>[optional]</strong> The time when the first paint happened. On Internet Explorer, this is milliseconds since the epoch, while on Chrome this is seconds.microseconds since the epoch. If you detect a decimal point in this number, multiply it by 1000 to compare it to the other timers.</td></tr>
</table> </table>


<p class="perma-link"> <p class="perma-link">
Expand Down
8 changes: 8 additions & 0 deletions plugins/navtiming.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ var impl = {
// secureConnectionStart is OPTIONAL in the spec // secureConnectionStart is OPTIONAL in the spec
data.nt_ssl_st = pt.secureConnectionStart; data.nt_ssl_st = pt.secureConnectionStart;
} }
if (pt.msFirstPaint) {
// msFirstPaint is IE9+ http://msdn.microsoft.com/en-us/library/ff974719
data.nt_first_paint = pt.msFirstPaint;
}


BOOMR.addVar(data); BOOMR.addVar(data);
} }


// XXX Inconsistency warning. msFirstPaint above is in milliseconds while
// firstPaintTime below is in seconds.microseconds. The server needs to deal with this.

// This is Chrome only, so will not overwrite nt_first_paint above
if(w.chrome && w.chrome.loadTimes) { if(w.chrome && w.chrome.loadTimes) {
pt = w.chrome.loadTimes(); pt = w.chrome.loadTimes();
if(pt) { if(pt) {
Expand Down

0 comments on commit ab63b25

Please sign in to comment.