]> git.cworth.org Git - cworth.org/blob - src/trender_bookmark.mdwn
Add render_bench post
[cworth.org] / src / trender_bookmark.mdwn
1 [[meta title="On-demand Trender"]]
2
3 [[tag performance]]
4
5 Vladimir Vukićević pointed me to an old [blog
6 entry](http://blog.vlad1.com/archives/2005/10/28/74/) where he
7 provides a useful "bookmarklet" that I thought I'd share. It makes it
8 easy to measure how long mozilla spends rendering any particular web
9 page.
10
11 My version is slightly tweaked from Vladimir's and is available here:
12 <a href="javascript:c=300;skip=4;wh=1024;ww=1024;window.resizeTo(wh,ww);
13 var wu=window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
14 r = new Array(); for (var i = 0; i < c; i++) { var start = Date.now();
15 wu.redraw(); var end = Date.now(); r.push(end - start); } var t=0;
16 (r.slice(skip)).forEach(function(v){t+=v;});dump('Average: ' +
17 (t/(c-skip)).toFixed(3) + ' \nRaw: ' + r);">Time Render</a>.
18
19 The differences in mine are that it runs for 300 iterations by default
20 instead of just 10, (long enough to collect very healthy profile
21 information), and that it emits its result by dumping to stdout or
22 stderr instead of popping up an alert box. Not only is the alert box
23 hard to use when it has 300 values laid out without line-wrapping,
24 but I do X server experiments where I need to measure performance even
25 when things are rendering incorrectly, (so if the results are only
26 displayed on the X server they are useless to me).
27
28 To use this, first you'll need a recent Firefox, (I'm using a daily
29 build here which works, where the system 2.0 version does not seem
30 to). Just drag-and-drop the above link to the bookmark toolbar, (and
31 yes, I had to turn it on just for that). You might also need to go to
32 the "about:config" location in the toolbar and create a new Boolean
33 entry, (right-click to find that), named
34 `browser.dom.window.dump.enabled` and set it to `True`.
35
36 At that point you should be all setup. Just browse to a web page of
37 interest and click the "Time Render" bookmark to measure the rendering
38 performance of Mozilla on that page.
39