示例#1
0
# metric type constants
define('BYTES', 0);
define('PERCENT_GRADE', 1);
define('MS', 2);
define('NUMBER', 3);
define('PERCENTS', 4);
# used for legend (in parenthesis)
# if no label needed like for number, just don't insert it here
$metric_types = array(BYTES => array('legend' => 'in bytes', 'units' => ' bytes'), MS => array('legend' => 'in ms', 'units' => ' ms'), PERCENT_GRADE => array('legend' => '0-100', 'units' => '%'), NUMBER => array('legend' => '', 'units' => ''), PERCENTS => array('legend' => '0-100', 'units' => '%'));
# defaults values for MySQL host and port
$host = 'localhost';
$port = 3306;
# config will override defaults above
require_once dirname(__FILE__) . '/config.php';
# a list of metrics (excluding custom metrics) available to be displayed on the graph
$all_metrics = array('yslow' => array('title' => 'YSlow', 'url' => 'http://developer.yahoo.com/yslow/', 'table' => 'yslow2', 'score_name' => 'grade', 'score_column' => 'o', 'metrics' => array('Basic measurements' => array(array('Overall rank', 'o', PERCENT_GRADE), array('Page Size', 'w', BYTES), array('Amount of requests with empty cache', 'r', NUMBER), array('Page Load time', 'lt', MS)), 'Best practices' => array(array('Make fewer HTTP requests', 'ynumreq', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#num_http'), array('Use a Content Delivery Network (CDN)', 'ycdn', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#cdn'), array('Add Expires headers', 'yexpires', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#expires'), array('Avoid Empty Image src', 'yemptysrc', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#emptysrc'), array('Compress components with gzip', 'ycompress', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#gzip'), array('Put CSS at top', 'ycsstop', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#css_top'), array('Put JavaScript at bottom', 'yjsbottom', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#js_bottom'), array('Avoid CSS expressions', 'yexpressions', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#css_expressions'), array('Make JavaScript and CSS external', 'yexternal', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#external'), array('Reduce DNS lookups', 'ydns', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#dns_lookups'), array('Minify JavaScript and CSS', 'yminify', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#minify'), array('Avoid URL redirects', 'yredirects', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#redirects'), array('Remove duplicate JavaScript and CSS', 'ydupes', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#js_dupes'), array('Configure entity tags (ETags)', 'yetags', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#etags'), array('Make AJAX cacheable', 'yxhr', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#cacheajax'), array('Use GET for AJAX requests', 'yxhrmethod', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#ajax_get'), array('Reduce the number of DOM elements', 'ymindom', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#min_dom'), array('Avoid HTTP 404 (Not Found) error', 'yno404', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#no404'), array('Reduce cookie size', 'ymincookie', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#cookie_size'), array('Use cookie-free domains', 'ycookiefree', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#cookie_free'), array('Avoid AlphaImageLoader filter', 'ynofilter', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#no_filters'), array('Do not scale images in HTML', 'yimgnoscale', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#no_scale'), array('Make favicon small and cacheable', 'yfavicon', PERCENT_GRADE, 'http://developer.yahoo.com/performance/rules.html#favicon')))), 'pagespeed' => array('title' => 'Page Speed', 'url' => 'http://code.google.com/speed/page-speed/', 'table' => 'pagespeed', 'score_name' => 'score', 'score_column' => 'o', 'metrics' => array('Basic measurements' => array(array('Page size', 'w', BYTES), array('Page load time', 'l', MS), array('Transfer size of all resources', 't', BYTES), array('Total Requests', 'r', NUMBER), array('Overall grade', 'o', PERCENT_GRADE)), 'Optimize caching' => array(array('Leverage browser caching', 'pBrowserCache', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching'), array('Leverage proxy caching', 'pCacheValid', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/caching.html#LeverageProxyCaching'), array('Remove query strings from static resources', 'pRemoveQuery', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching'), array('Specify a Vary: Accept-Encoding header', 'pVaryAE', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching')), 'Minimize round-trip times' => array(array('Minimize DNS lookups', 'pMinDns', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#MinimizeDNSLookups'), array('Minimize redirects', 'pMinRedirect', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#AvoidRedirects'), array('Avoid bad requests', 'pBadReqs', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#AvoidBadRequests'), array('Combine external JavaScript', 'pCombineJS', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#CombineExternalJS'), array('Combine external CSS', 'pCombineCSS', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#CombineExternalCSS'), array('Combine images using CSS sprites', 'pSprite', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#SpriteImages'), array('Optimize the order of styles and scripts', 'pCssJsOrder', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#PutStylesBeforeScripts'), array('Avoid document.write', 'pDocWrite', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#AvoidDocumentWrite'), array('Avoid CSS @import', 'pCssImport', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#AvoidCssImport'), array('Prefer asynchronous resources', 'pPreferAsync', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#PreferAsyncResources'), array('Parallelize downloads across hostnames', 'pParallelDl', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rtt.html#ParallelizeDownloads')), 'Minimize request overhead' => array(array('Minimize request size', 'pMinReqSize', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/request.html#MinimizeRequestSize'), array('Serve static content from a cookieless domain', 'pNoCookie', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain')), 'Minimize payload size' => array(array('Enable compression', 'pGzip', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#GzipCompression'), array('Remove unused CSS', 'pUnusedCSS', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#RemoveUnusedCSS'), array('Minify JavaScript', 'pMinifyJS', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#MinifyJS'), array('Minify CSS', 'pMinifyCSS', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#MinifyCSS'), array('Minify HTML', 'pMinifyHTML', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#MinifyHTML'), array('Defer loading of JavaScript', 'pDeferJS', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS'), array('Optimize images', 'pOptImgs', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#CompressImages'), array('Serve scaled images', 'pScaleImgs', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#ScaleImages'), array('Serve resources from a consistent URL', 'pDupeRsrc', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/payload.html#duplicate_resources')), 'Optimize browser rendering' => array(array('Use efficient CSS selectors', 'pCssSelect', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rendering.html#UseEfficientCSSSelectors'), array('Put CSS in the document head', 'pCssInHead', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rendering.html#PutCSSInHead'), array('Specify image dimensions', 'pImgDims', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImageDimensions'), array('Specify a character set early', 'pCharsetEarly', PERCENT_GRADE, 'http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyCharsetEarly')))), 'dynatrace' => array('title' => 'dynaTrace', 'url' => 'http://ajax.dynatrace.com/', 'table' => 'dynatrace', 'score_name' => 'rank', 'score_column' => 'rank', 'metrics' => array('Event times' => array(array('Time to first impression', 'timetoimpression', MS), array('Time to onLoad', 'timetoonload', MS), array('Time to full page load', 'timetofullload', MS)), 'Total time breakdown' => array(array('Total time on network', 'timeonnetwork', MS), array('Total time in JavaScript', 'timeinjs', MS), array('Total time in rendering', 'timeinrendering', MS)), 'Requests and size' => array(array('Number of requests', 'reqnumber', NUMBER), array('Number of XHR requests', 'xhrnumber', NUMBER), array('Total page size', 'pagesize', BYTES), array('Total cachable size', 'cachablesize', BYTES), array('Total non-cachable size', 'noncachablesize', BYTES)), 'Best practices' => array(array('Overall rank', 'rank', PERCENT_GRADE), array('Caching rank', 'cache', PERCENT_GRADE, 'https://community.dynatrace.com/community/display/PUB/Best+Practices+on+Browser+Caching'), array('Network rank', 'net', PERCENT_GRADE, 'https://community.dynatrace.com/community/display/PUB/Best+Practices+on+Network+Requests+and+Roundtrips'), array('Server rank', 'server', PERCENT_GRADE, 'https://community.dynatrace.com/community/display/PUB/Best+Practices+on+Server-Side+Performance+Optimization'), array('JavaScript rank', 'js', PERCENT_GRADE, 'https://community.dynatrace.com/community/display/PUB/Best+Practices+on+JavaScript+and+AJAX+Performance')))), 'dommonster' => array('title' => 'DOM Monster', 'description' => '<p>To send data to this instance, drag <a style="padding: 3px 4px; margin: 0 3px; background: #dfdfdf; border: 1px solid gray; color: black; text-decoration: none; font-size: xx-small; font-family: verdana" href="javascript:(function(){SHOWSLOWINSTANCE%20=\'' . $showslow_base . '\';var%20script=document.createElement(\'script\');script.src=\'' . assetURL('beacon/dommonster/dom-monster/src/dommonster.js') . '?\'+Math.floor((+new Date));document.body.appendChild(script);})()">DOM Monster!</a> bookmarklet to your toolbar and click "send to Show Slow" button when report is shown.</p>', 'url' => 'http://mir.aculo.us/dom-monster/', 'table' => 'dommonster', 'metrics' => array('DOM Statistics' => array(array('Number of elements', 'elements', NUMBER, null, 'levels', array(750, 1500)), array('Number of DOM nodes', 'nodecount', NUMBER, null, 'levels', array(1500, 3000)), array('Number of Text nodes', 'textnodes', NUMBER, null, 'levels', array(750, 1500)), array('Size of Text nodes', 'textnodessize', BYTES, null, 'levels', array(80000, 500000)), array('Content percentage', 'contentpercent', PERCENTS, null, 'reverselevels', array(25, 50)), array('Average nesting depth', 'average', NUMBER, null, 'levels', array(8, 15)), array('Serialized DOM size', 'domsize', BYTES, null, 'levels', array(100 * 1024, 250 * 1024)), array('DOM tree serialization time', 'bodycount', MS, null, 'levels', array(500, 1000))))), 'webpagetest' => array('title' => 'WebPageTest', 'description' => 'Data sent from WebPageTest instance located at <a href="' . $webPageTestBase . '" target="_blank">' . $webPageTestBase . '</a>', 'url' => 'http://www.webpagetest.org/', 'table' => 'pagetest', 'score_name' => 'score', 'metrics' => array('First view' => array(array('Load Time', 'f_LoadTime', MS), array('Time to first byte', 'f_TTFB', MS), array('Time to first render', 'f_render', MS), array('Above the fold time', 'f_aft', MS), array('Number of DOM elements', 'f_domElements', NUMBER), array('Number of connections', 'f_connections', NUMBER)), 'First view (Document Complete)' => array(array('Load Time', 'f_docTime', MS), array('Number of requests', 'f_requestsDoc', NUMBER), array('Bytes In', 'f_bytesInDoc', BYTES)), 'First view (Fully Loaded)' => array(array('Load Time', 'f_fullyLoaded', MS), array('Number of requests', 'f_requests', NUMBER), array('Bytes In', 'f_bytesIn', BYTES)), 'First view Rankings Scores' => array(array('Persistent connections (keep-alive)', 'f_score_keep_alive', PERCENT_GRADE), array('GZIP text', 'f_score_gzip', PERCENT_GRADE), array('Total size of compressible text', 'f_gzip_total', BYTES), array('Potential text compression savings', 'f_gzip_savings', BYTES), array('Compress Images', 'f_score_compress', PERCENT_GRADE), array('Total size of compressible images', 'f_image_total', BYTES), array('Potential image compression savings', 'f_image_savings', BYTES), array('Cache Static', 'f_score_cache', PERCENT_GRADE), array('Combine CSS/JS', 'r_score_combine', PERCENT_GRADE), array('Use a CDN', 'f_score_cdn', PERCENT_GRADE), array('Minify JavaScript', 'f_score_minify', PERCENT_GRADE), array('Total size of minifiable text', 'f_minify_total', BYTES), array('Potential text minification savings', 'f_minify_savings', BYTES), array('No cookies for static assets', 'f_score_cookies', PERCENT_GRADE), array('No Etags', 'f_score_etags', PERCENT_GRADE)), 'Repeat view' => array(array('Load Time', 'r_LoadTime', MS), array('Time to first byte', 'r_TTFB', MS), array('Time to first render', 'r_render', MS), array('Above the fold time', 'r_aft', MS), array('Number of DOM elements', 'r_domElements', NUMBER), array('Number of connections', 'f_connections', NUMBER)), 'Repeat view (Document Complete)' => array(array('Load Time', 'r_docTime', MS), array('Number of requests', 'r_requestsDoc', NUMBER), array('Bytes In', 'r_bytesInDoc', BYTES)), 'Repeat view (Fully Loaded)' => array(array('Load Time', 'r_fullyLoaded', MS), array('Number of requests', 'r_requests', NUMBER), array('Bytes In', 'r_bytesIn', BYTES)), 'Repeat view Rankings Scores' => array(array('Persistent connections (keep-alive)', 'f_score_keep_alive', PERCENT_GRADE), array('GZIP text', 'f_score_gzip', PERCENT_GRADE), array('Total size of compressible text', 'f_gzip_total', BYTES), array('Potential text compression savings', 'f_gzip_savings', BYTES), array('Compress Images', 'f_score_compress', PERCENT_GRADE), array('Total size of compressible images', 'f_image_total', BYTES), array('Potential image compression savings', 'f_image_savings', BYTES), array('Cache Static', 'f_score_cache', PERCENT_GRADE), array('Combine CSS/JS', 'r_score_combine', PERCENT_GRADE), array('Use a CDN', 'f_score_cdn', PERCENT_GRADE), array('Minify JavaScript', 'f_score_minify', PERCENT_GRADE), array('Total size of minifiable text', 'f_minify_total', BYTES), array('Potential text minification savings', 'f_minify_savings', BYTES), array('No cookies for static assets', 'f_score_cookies', PERCENT_GRADE), array('No Etags', 'f_score_etags', PERCENT_GRADE)))));
function prettyScore($num)
{
    $letter = 'F';
    if (90 <= $num) {
        $letter = 'A';
    } else {
        if (80 <= $num) {
            $letter = 'B';
        } else {
            if (70 <= $num) {
                $letter = 'C';
            } else {
                if (60 <= $num) {
                    $letter = 'D';
                } else {
示例#2
0
                                ?>
				<td class="score" style="color: silver" title="No data collected">no data</td>
				<td><div class="gbox" title="No data collected"><div class="bar"/></div></td>
			<?php 
                            }
                        }
                        ?>
		<?php 
                    } else {
                        ?>
			<td style="text-align: right; padding-right: 1em" title="Data for this URL is being collected"><i>collecting data</i></td>
			<?php 
                        for ($i = 0; $i < $cols; $i++) {
                            ?>
			<td class="score" style="color: silver" title="Collecting data"><img style="vertical-align: text-bottom" src="<?php 
                            echo assetURL('clock.png');
                            ?>
"/></td>
			<td title="Collecting data"><div class="gbox"><div class="bar ccol"/></div></td>
			<?php 
                        }
                        ?>
		<?php 
                    }
                }
            }
        }
        ?>
		<td style="text-align: center"><input type="submit" name="delete[<?php 
        echo htmlentities($row['id']);
        ?>
示例#3
0
<?php 
if ($extraHeadHTML) {
    echo $extraHeadHTML;
}
?>
</head>
<body>
<div class="stack">
	<div id="header">
		<div class="stackContent">
			<h1 style="color: white"><a href="<?php 
echo $showslow_base;
?>
"><img src="<?php 
echo assetURL('img/logo-shadow.png');
?>
" width="72" height="70" alt="Show Slow" /></a> Is your website <b>getting faster</b>?
				<?php 
if ($enableMyURLs && is_null($current_user)) {
    ?>
<a class="btn btn-warning" href="<?php 
    echo $showslow_base . '/users/register.php';
    ?>
">Sign up now!</a><?php 
}
?>
			</h1>

<?php 
if ($enableMyURLs) {
示例#4
0
function image($path, $options = '')
{
    return "<img src='" . assetURL("images/{$path}") . "' " . html_options($options) . ">\n";
}
示例#5
0
        </div>
    </fieldset>
    </form>
    
    <!--[if lte IE 8]>
    <script language="javascript" type="text/javascript" src="../flot/excanvas.min.js"></script>
    <![endif]-->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    <script src="<?php 
echo assetURL('flot/jquery.flot.js');
?>
"></script>
    <script src="<?php 
echo assetURL('flot/jquery.flot.crosshair.js');
?>
"></script>
    <script src="<?php 
echo assetURL('flot/jquery.flot.selection.js');
?>
"></script>
    <script src="<?php 
echo assetURL('flot/jquery.flot.resize.js');
?>
"></script>
    <script src="<?php 
echo assetURL('details/showslow.flot.js');
?>
"></script>
</body>
</html>
示例#6
0
    ?>
?'+Math.floor((+new Date));document.body.appendChild(script);})()">DOM Monster!</a> bookmarklet to your toolbar and click "send to Show Slow" button when report is shown.</p>

<h2>Installing on mobile devices</h2>

<h3>Method 1</h3>
<p>Bookmark this link: <a href="#<?php 
    echo urlencode("javascript:(function(){SHOWSLOWINSTANCE ='{$showslow_base}';var script=document.createElement('script');script.src='" . assetURL('beacon/dommonster/dom-monster/src/dommonster.js') . "?'+Math.floor((+new Date));document.body.appendChild(script);})()");
    ?>
">DOM Monster + ShowSlow</a> and then edit it removing everything up to # symbol.</p>
<h3>Method 2</h3>
<p>
<ol>
<li>Go to this page and bookmark it: <a href="install.php">DOM Monster + ShowSlow</a></li>
<li>Select all code from the field below and copy to your clipboard<br/>
<input style="width: 100%; font-size: 1em" type="text" value="javascript:(function(){SHOWSLOWINSTANCE%20='<?php 
    echo $showslow_base;
    ?>
';var%20script=document.createElement('script');script.src='<?php 
    echo assetURL('beacon/dommonster/dom-monster/src/dommonster.js');
    ?>
?'+Math.floor((+new Date));document.body.appendChild(script);})()"/></li>
<li>Edit bookmarklet you created in step one and paste the code instead of the URL of the page</li>
</ol>
</p>
<hr/>
<p><a href="../">&lt;&lt; back to the list of beacons</a></p>
</body></html>
<?php 
    exit;
}
示例#7
0
    if ($counters['pagespeed'] > 0) {
        $default = 'pagespeed';
    }
    if ($counters['yslow'] > 0) {
        $default = 'yslow';
    }
    // if there is data for the urls then use default ranker, otherwise display a form
    if (!is_null($default)) {
        header('Location: ?ranker=' . $default . '&' . $params);
        exit;
    }
}
// if some URLs passed, add them to the title and load javascripts
if (!$badinput) {
    $TITLE .= ' for: ' . implode(', ', $urls);
    $SCRIPTS = array('http://yui.yahooapis.com/combo?2.8.1/build/yahoo/yahoo-min.js&2.8.1/build/event/event-min.js&2.8.1/build/yuiloader/yuiloader-min.js', $showslow_base . 'ajax/simile-ajax-api.js?bundle=true', $showslow_base . 'timeline/timeline-api.js?bundle=true', $showslow_base . 'timeplot/timeplot-api.js?bundle=true', assetURL('details/compare.js'));
}
$SECTION = 'compare';
require_once dirname(dirname(__FILE__)) . '/header.php';
?>
<style>
.details {
	cursor: help;
}
</style>

<h2 style="margin-bottom: 0">Compare rankings</h2>
<?php 
// only display menu if user picked the ranker specifically
// (otherwise either there is no data or we don't reach this point and get redirected to default)
if (!is_null($ranker)) {
示例#8
0
        }
        ?>

	<?php 
        if (!$wpt) {
            ?>
	<?php 
        } else {
            if (is_null($row['wpt_test_id'])) {
                ?>
		<td style="color: silver" title="No data collected">no data</td>
	<?php 
            } else {
                ?>
		<td title="WebPageTest test results"><img src="<?php 
                echo assetURL('/img/webpagetest-12h.png');
                ?>
"/> <a href="<?php 
                echo detailsUrl($row['url_id'], $row['url']);
                ?>
#webpagetest">test results</a></td>
	<?php 
            }
        }
        ?>

	<td class="url"><a href="<?php 
        echo detailsUrl($row['url_id'], $row['url']);
        ?>
"><?php 
        echo htmlentities(substr($row['url'], 0, 100));