/
results.php
368 lines (329 loc) · 13.2 KB
/
results.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<?php
/*
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
See the source code here:
http://code.google.com/p/loadtimer/
*/
require_once("db.inc");
$gData = "blog";
$gRange = "createdate >= 1322599749 and createdate <= 1322606100";
if ( array_key_exists("data", $_GET) ) {
if ( "all" === $_GET["data"] ) {
$gData = "all";
$gRange = "createdate > 0";
}
if ( "silkupdate" === $_GET["data"] ) {
$gData = "silkupdate";
$gRange = "createdate >= 1327107439 and createdate <= 1327111855";
}
}
$ghUrls = array(
// no load "http://www.google.com/search?q=flowers",
// no load "http://www.facebook.com/",
"http://www.yahoo.com/" => "Yahoo",
// no load "http://www.youtube.com/",
"http://www.amazon.com/" => "Amazon",
"http://en.wikipedia.org/wiki/Flowers" => "Wikipedia",
// no load "http://www.twitter.com/",
"http://www.craigslist.com/" => "Craigslist",
"http://www.ebay.com/" => "eBay",
"http://www.linkedin.com/" => "LinkedIn",
"http://www.bing.com/search?q=flowers" => "Bing",
"http://www.msn.com/" => "MSN",
// framebuster "http://www.nytimes.com/",
"http://www.engadget.com/" => "Engadget",
"http://www.cnn.com/" => "CNN",
"http://www.reddit.com/" => "Reddit"
);
// "SU" == "Silk Update"
$ghUrlsSU = array(
"http://www.backlinkfuel.com/" => "Backlink Fuel",
"http://www.renesas.com/" => "Renesas",
"http://www.bookmarkspad.com/" => "BookmarksPad",
"http://www.gobignetwork.com/" => "Go BIG Network",
"http://www.money.co.uk/" => "Money UK",
// #11 "http://www.choosewhat.com/" => "ChooseWhat",
// #11 "http://www.autocompletepro.com/" => "AutoCompletePro",
"http://www.car.org/" => "CA Realtors",
"http://www.venturehacks.com/" => "Venture Hacks",
"http://www.maidenform.com/" => "Maidenform",
"http://www.sleepnumber.com/" => "Sleep Number",
"http://www.mass.edu/" => "Mass.edu"
);
if ( "silkupdate" === $gData ) {
unset($ghUrls["http://www.yahoo.com/"]);
$ghUrls = array_merge($ghUrls, $ghUrlsSU);
}
$ghExceptions = array();
$ghExceptions["Galaxy 7.0 SGH-T849"] = array();
$ghExceptions["Galaxy 7.0 SGH-T849"]["http://www.amazon.com/"] = 19;
$ghExceptions["Galaxy 7.0 SGH-T849"]["http://en.wikipedia.org/wiki/Flowers"] = 32;
$ghExceptions["Galaxy 7.0 SGH-T849"]["http://www.ebay.com/"] = 22;
$ghExceptions["Galaxy 7.0 SGH-T849"]["http://www.linkedin.com/"] = 2;
$ghExceptions["Galaxy 7.0 SGH-T849"]["http://www.bing.com/search?q=flowers"] = 7;
$ghExceptions["Galaxy 7.0 SGH-T849"]["http://www.cnn.com/"] = 20;
$ghExceptions["Galaxy 7"] = array();
$ghExceptions["Galaxy 7"]["http://www.amazon.com/"] = 19;
$ghExceptions["Galaxy 7"]["http://en.wikipedia.org/wiki/Flowers"] = 32;
$ghExceptions["Galaxy 7"]["http://www.ebay.com/"] = 22;
$ghExceptions["Galaxy 7"]["http://www.linkedin.com/"] = 2;
$ghExceptions["Galaxy 7"]["http://www.bing.com/search?q=flowers"] = 7;
$ghExceptions["Galaxy 7"]["http://www.cnn.com/"] = 20;
$ghExceptions["Galaxy 10.1 GT-P7510"] = array();
$ghExceptions["Galaxy 10.1 GT-P7510"]["http://www.linkedin.com/"] = 2;
$ghExceptions["Galaxy 10.1 GT-P7510"]["http://www.yahoo.com/"] = 46;
$ghExceptions["Galaxy 10"] = array();
$ghExceptions["Galaxy 10"]["http://www.linkedin.com/"] = 2;
$ghExceptions["Galaxy 10"]["http://www.yahoo.com/"] = 46;
$ghExceptions["Silk (accel off) 1.1.0"] = array();
$ghExceptions["Silk (accel off) 1.1.0"]["http://www.yahoo.com/"] = 58;
$ghExceptions["Silk (accel off) 1.1.0"]["http://www.ebay.com/"] = 18;
$ghExceptions["Silk (accel on) 1.1.0"] = array();
$ghExceptions["Silk (accel on) 1.1.0"]["http://www.yahoo.com/"] = 58;
$ghExceptions["Silk (accel on) 1.1.0"]["http://www.ebay.com/"] = 18;
$ghExceptions["Silk (accel off) 1"] = array();
$ghExceptions["Silk (accel off) 1"]["http://www.yahoo.com/"] = 58;
$ghExceptions["Silk (accel off) 1"]["http://www.ebay.com/"] = 18;
$ghExceptions["Silk (accel on) 1"] = array();
$ghExceptions["Silk (accel on) 1"]["http://www.yahoo.com/"] = 58;
$ghExceptions["Silk (accel on) 1"]["http://www.ebay.com/"] = 18;
$ghExceptions["iPad 2 5.0"] = array();
$ghExceptions["iPad 2 5.0"]["http://www.yahoo.com/"] = 23;
$ghExceptions["iPad 2 5"] = array();
$ghExceptions["iPad 2 5"]["http://www.yahoo.com/"] = 23;
$ghExceptions["iPad 1 5.0.1"] = array();
$ghExceptions["iPad 1 5.0.1"]["http://www.yahoo.com/"] = 60;
$ghExceptions["iPad 1 5"] = array();
$ghExceptions["iPad 1 5"]["http://www.yahoo.com/"] = 60;
$ghResources = array();
$ghResources["http://www.yahoo.com/"] = 67;
$ghResources["http://www.amazon.com/"] = 43;
$ghResources["http://en.wikipedia.org/wiki/Flowers"] = 50;
$ghResources["http://www.craigslist.com/"] = 4;
$ghResources["http://www.ebay.com/"] = 64;
$ghResources["http://www.linkedin.com/"] = 11;
$ghResources["http://www.bing.com/search?q=flowers"] = 13;
$ghResources["http://www.msn.com/"] = 47;
$ghResources["http://www.engadget.com/"] = 215;
$ghResources["http://www.cnn.com/"] = 124;
$ghResources["http://www.reddit.com/"] = 21;
// list of browsers
$gaBrowsers = array();
if ( array_key_exists("comparesel", $_GET) ) {
$aKeys = array_keys($_GET);
foreach($aKeys as $key) {
if ( 0 === strpos($key, "b_") ) {
$gaBrowsers[] = $_GET[$key];
}
}
}
if ( 0 === count($gaBrowsers) ) {
$query = "select browser from $gBeaconsTable where $gRange group by browser order by browser;";
$result = doQuery($query);
while ($row = mysql_fetch_assoc($result)) {
$browser = $row['browser'];
$gaBrowsers[] = $browser;
}
mysql_free_result($result);
}
// table column headers
$sTH = "<tr> <th>browser</th> ";
$aUrls = array_keys($ghUrls);
foreach($aUrls as $url) {
$sTH .= "<th class=sortnum><a href='$url' target='_blank'>" . $ghUrls[$url] . "</a></th> ";
}
$sTH .= "<th class=sortnum># data</th>" . "</tr>\n";
// track min & max (initialize values for each URL)
$ghMin = array();
$ghMax = array();
foreach($aUrls as $url) {
$ghMin[$url] = 9999999;
$ghMax[$url] = 0;
}
$ghMedians = array();
foreach($gaBrowsers as $browser) {
$ghMedians[$browser] = array();
foreach($aUrls as $url) {
$num = doSimpleQuery("select count(loadtime) as num from $gBeaconsTable where browser='$browser' and url='$url' and $gRange;");
if ( $num > 0 ) {
$median = doSimpleQuery("select loadtime as median from $gBeaconsTable where browser='$browser' and url='$url' and $gRange order by loadtime asc limit " .
floor(($num-1)/2) . ",1;");
$ghMedians[$browser][$url] = $median;
if ( array_key_exists($browser, $ghExceptions) && array_key_exists($url, $ghExceptions[$browser]) ) {
// don't let exceptions take the min
}
else if ( $median < $ghMin[$url] ) {
$ghMin[$url] = $median;
}
if ( $median > $ghMax[$url] ) {
$ghMax[$url] = $median;
}
}
}
$ghMedians[$browser]['num'] = $num; // bogus if URLs have different # of beacons
}
$sRows = "";
$iBrowser = 0;
foreach($gaBrowsers as $browser) {
$iBrowser++;
$sRow = "<tr> <td class=browser><input type=checkbox name='b_$iBrowser' value='$browser' checked> $browser</td> ";
foreach($aUrls as $url) {
$median = $ghMedians[$browser][$url];
$class = "sortnum";
if ( intval($median) < intval($ghMin[$url]) ) {
$class .= " minexc";
}
else if ( intval($median) == intval($ghMin[$url]) ) {
$class .= " min";
}
else if ( intval($median) == intval($ghMax[$url]) ) {
$class .= " max";
}
else {
$class .= " num";
}
$data = "";
if ( $median ) {
$data = commaize($median) . "<br>(" .
( array_key_exists($browser, $ghExceptions) && array_key_exists($url, $ghExceptions[$browser]) ?
$ghExceptions[$browser][$url] : $ghResources[$url] ) . ")";
}
$sRow .= "<td class='$class" . ( array_key_exists($browser, $ghExceptions) && array_key_exists($url, $ghExceptions[$browser]) ? " exc" : "" ) .
"'>" . "$data</td> ";
}
$num = $ghMedians[$browser]['num'];
$sRow .= "<td class='sortnum'>$num</td> " . "</tr>\n";
if ( $num ) {
$sRows .= $sRow;
}
}
// add commas to a big number
function commaize($num) {
$sNum = "$num";
$len = strlen($sNum);
if ( $len <= 3 ) {
return $sNum;
}
return commaize(substr($sNum, 0, $len-3)) . "," . substr($sNum, $len-3);
}
?>
<!doctype html>
<html>
<head>
<title>Loadtimer Results</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
body { font: .813em "Lucida Grande","Lucida Sans Unicode",sans-serif; color: #333; line-height: 1.4em; padding: 8px; }
code { font-size: 1.2em; }
h1 { font: 2em Arial, Helvetica, sans-serif; color: #1D2432; font-weight: bold; margin-bottom: .8em; }
h2 { font: 1.75em Arial, Helvetica, sans-serif; font-weight: bold; margin-bottom: .5em; }
h3 { font: 1.5em Arial, Helvetica, sans-serif; font-weight: bold; margin-bottom: .5em; }
h3 a { color: #FFF; text-decoration: none; }
h3 a:hover { text-decoration: underline; }
h4 { font: 1.25em Arial, Helvetica, sans-serif;font-weight: bold; margin-bottom: .5em; }
ul, ol { font-size: 1em; margin: 0 0 1.25em 1.538em; }
li { margin-bottom: .25em; }
p { margin-bottom: 1em; }
p.meta { font: .923em Arial, Helvetica, sans-serif; color: #43768B; }
p.meta a { color: #43768B; }
p.meta a:hover { color: #973100; }
a { color: #315667; }
a:hover, #sidebar a:hover { color: #973100; }
dt { margin-left: 1em; }
dd { margin-left: 2em; margin-bottom: .25em; }
dl { margin: 0 0 1.25em 0; }
#navlinks LI { display: inline; margin: 0 8px; }
#footer { margin-top: 2em; width: 800px; text-align: center; }
</style>
</head>
<body>
<span style="position: absolute; left: 500px;">
<ul id=navlinks>
<li> <a href="index.php">harness</a>
<li> <a href="#about">about</a>
<li> <a href="http://code.google.com/p/loadtimer/">code</a>
<li> <a href="http://groups.google.com/group/loadtimer/topics">contact</a>
</ul>
</span>
<h1 style="color: #353335; font-size: 2.5em;">
<a href="index.php" style="text-decoration: none; color: #353335;"><img src="loadtimer-42x42.gif" style="vertical-align: bottom; border: 0;"></a>
<a href="results.php" style="text-decoration: none; color: #353335;"> Loadtimer Results</a>
</h1>
<div style="padding: 8px;">
<style>
TH { padding: 4px 8px 4px 8px; border-bottom: 2px solid #222; }
TD { text-align: right; padding: 4px 10px 4px 4px; border-bottom: 1px solid #777; }
TD.browser { text-align: left; }
.tablelabel { font-weight: bold; padding: 1em 0 0.5em 0; margin-left: 10em; }
TD.sortnum { font-family: monospace; font-size: 1.1em; }
.num { color: #333; }
.min { color: #292; font-weight: bold; }
.max { color: #F00; font-weight: bold; }
.minexc { color: #292; }
.exc { background: #E8E8E8; }
</style>
<p>
These are the median page load times for popular websites.
The times are in milliseconds.
The number of resources is shown in parentheses.
</p>
<ul>
<li> Devices that receive mobile-specific versions of the site have a <span class=exc style="padding: 0 8px;">gray background</span>.
<li> The slowest time is shown in <span class=max>red</span>.
<li> The fastest time is shown in <span class=min>green</span> for devices that received the desktop version.
<li> Devices that received a mobile version of the site and were faster than the desktop version are shown in <span class=minexc><span class=exc style="padding: 0 8px;">non-bold green (with a gray background)</span></span>.
</ul>
<form>
<div class=tablelabel>Table 1: Median page load time (milliseconds)</div>
<table class='tablesort' cellpadding=0 cellspacing=0 border=0 style="margin-bottom: 1em;">
<?php
echo $sTH;
echo $sRows;
?>
</table>
<input type=submit name=comparesel value="Compare Selected">
<input type=button value="Reset" onclick="document.location='results.php'">
<div style="margin-top: 0.5em;">
<input type=radio name=data value="blog" onchange="document.location='results.php?data=blog'"<?php echo ( "blog" === $gData ? " checked" : "" ) ?>> blog post's data
<br>
<input type=radio name=data value="silkupdate" onchange="document.location='results.php?data=silkupdate'"<?php echo ( "silkupdate" === $gData ? " checked" : "" ) ?>> Silk update data
<br>
<input type=radio name=data value="all" onchange="document.location='results.php?data=all'"<?php echo ( "all" === $gData ? " checked" : "" ) ?>> all data (including public)
</div>
</form>
<script type="text/javascript">
var tsjs = document.createElement('script');
tsjs.src = "tablesort.js";
tsjs.onload = function() { TS.init(); };
tsjs.onreadystatechange = function() { if ( tsjs.readyState == 'complete' || tsjs.readyState == 'loaded' ) { TS.init(); } };
document.getElementsByTagName('head')[0].appendChild(tsjs);
</script>
</div> <!-- wrapper -->
</body>
</html>