Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Page size (sz) and Estimated Arrival (ea) #5

Open
wants to merge 1 commit into from

2 participants

@symcbean

(fingers crossed I've managed to get this right - this is my first time playing with git)

Page size is mod to BW which reports the size of the current HTML page using document.documentElement.innerHTML.length. The code here differs from that I had previously posted on the discussion board - I've now added a new method which subscribes to the before_beacon event (had problems using page_ready within BW). Using Dokuwiki to generate some test pages, I saw a very consistent relationship between sz and the %b figure in the logs - more specifically,

%b = sz - 1016 +/- 70

As per my comments on the discussion board, embedding the arrival time snapshot into the boomerang code is not ideal - but makes for a cleaner implementation - and its overridden if webtiming is available.

@bluesmoon

I'm not sure how useful the page size is. It doesn't consider the size of additional assets, whether content was gzipped over the network or not, whether it was read in from cache or not and also considers dynamically added content that wasn't necessarily downloaded, but is still in the document.

The idea is interesting, but I'm not sure this is the right number to capture. What do you think?

@symcbean

Ideally I want to know how long it took the server to generate the content, independently of the additional files that go to make up the page. I don't think I can measure this directly on the client (see also my post on the first byte metric on the discussion board).

Knowing the document size, bandwidth, HTTP latency and the time between the request start and the current request completing (rather than the full page) should allow me to calculate the server time. So despite 2 changes across 2 plugins to get 2 new metrics, really I'm trying to get a single value out of the system.

There are caveats on this:
1) I am seeing variations in the relationship between 'sz' and '%b' which seem to be related to the structure of the page (javascript, CSS). So far I've only tested using dokuwiki and some plain html and php pages, however the relationship seems to be highly linear. So for a single site (leaving aside other considerations - see below) it should be possible to calculate the size of the document accurately.

2) Agreed there are a lot of things which could cause 'sz' to not reflect what was sent over the network - I work predominantly with SaaS apps - and the HTML is exclusively dynamically generated, and there is very little other content which is not static. So the HTML is never cached. Regarding compression, yes this could be a problem, however I'd expect a fairly predictable relationship between raw and compressed content. But I admit I don't currently have stats to back this up.

So yes, there are some assumptions here - ultimately the value (at least from my point of view) is whether the resulting metrics are reasonably accurate - or at least allow an accurate metric to be derived. And that needs to be determined experimentally. This is still a work in progress.

If you can suggest a better way of measuring server time on the client, I'm keen to hear more!

@bluesmoon

So while I think might be a useful metric, I don't think it's generic enough in its current form to be part of the core plugins. Furthermore, to get a more accurate measure, I'd get my server side scripting language to do more work (we do this a lot at Yahoo!). For example, in PHP, I'd do this:

https://gist.github.com/774939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 3 deletions.
  1. +29 −3 boomerang.js
View
32 boomerang.js
@@ -478,6 +478,7 @@ BOOMR.plugins = BOOMR.plugins || {};
(function(w) {
var d=w.document;
+var ea=new Date().getTime();
BOOMR = BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};
@@ -615,6 +616,10 @@ BOOMR.plugins.RT = {
// becomes standard (2012? 2014?) Scream at me if you see this past 2012
BOOMR.warn("start cookie not set, trying WebTiming API", "rt");
+
+ // if we've no start time, no point comparing with the arrival time
+ ea=0;
+
// Get start time from WebTiming API see:
// http://dev.w3.org/2006/webapi/WebTiming/
// http://blogs.msdn.com/b/ie/archive/2010/06/28/measuring-web-page-performance.aspx
@@ -645,6 +650,10 @@ BOOMR.plugins.RT = {
|| ti.fetchStart
|| ti.navigationStart
|| undefined;
+ if (!ea || ti.responseEnd<ea) {
+ ea=ti.responseEnd;
+ }
+
}
else {
BOOMR.warn("This browser doesn't support the WebTiming API", "rt");
@@ -652,7 +661,7 @@ BOOMR.plugins.RT = {
}
// make sure old variables don't stick around
- BOOMR.removeVar('t_done', 't_page', 't_resp', 'u', 'r', 'r2');
+ BOOMR.removeVar('t_done', 't_page', 't_resp', 'u', 'r', 'r2', 'ea');
for(t_name in impl.timers) {
if(!impl.timers.hasOwnProperty(t_name)) {
@@ -687,7 +696,7 @@ BOOMR.plugins.RT = {
// At this point we decide whether the beacon should be sent or not
if(ntimers) {
- BOOMR.addVar({ "u": u, "r": r });
+ BOOMR.addVar({ "u": u, "r": r, "ea": ea - t_start});
if(r2 !== r) {
BOOMR.addVar("r2", r2);
@@ -1106,6 +1115,7 @@ var impl = {
}
this.complete = true;
+ // NB the following line may result in an additional fire when the BW checks are run
BOOMR.sendBeacon();
this.running = false;
},
@@ -1182,10 +1192,14 @@ BOOMR.plugins.BW = {
impl.complete = false;
impl.aborted = false;
- BOOMR.removeVar('ba', 'ba_err', 'lat', 'lat_err');
+ BOOMR.removeVar('ba', 'ba_err', 'lat', 'lat_err', 'sz');
cookies = BOOMR.utils.getSubCookies(BOOMR.utils.getCookie(impl.cookie));
+ // with page_ready, fetch_sz seems to fire every time but only reported to beacon
+ // when BW checks run?
+ BOOMR.subscribe("before_beacon", this.fetch_sz, null, this);
+
if(!cookies || !cookies.ba || !impl.setVarsFromCookie(cookies)) {
BOOMR.subscribe("page_ready", this.run, null, this);
}
@@ -1218,6 +1232,18 @@ BOOMR.plugins.BW = {
return this;
},
+ fetch_sz: function () {
+ // By the time this fires, using my stress test rig (running Dokuwiki) the
+ // page size has changed in FF3 from the value detected at onload()
+ // There will also be problems in the caluclation using multi-byte charsets
+
+ var sz=document.documentElement.innerHTML.length;
+ BOOMR.debug("fetch_sz fired="+sz,"bw");
+ BOOMR.addVar({
+ 'sz': sz
+ });
+ },
+
abort: function() {
impl.aborted = true;
impl.finish(); // we don't defer this call because it might be called from
Something went wrong with that request. Please try again.