Bug 727705 - remove two copies of pageloader from m-c. r=jmaher

This commit is contained in:
Jeff Hammel 2012-02-22 09:24:29 -05:00
Родитель d796c62bf2
Коммит 19e2d4a7dc
21 изменённых файлов: 0 добавлений и 1578 удалений

Просмотреть файл

@ -77,7 +77,6 @@ PARALLEL_DIRS += \
$(NULL)
TOOL_DIRS += tools/reftest reftests/fonts reftests/fonts/mplus
DIRS += tools/pageloader
ifdef MOZ_DEBUG
DIRS += tools/layout-debug

Просмотреть файл

@ -1,52 +0,0 @@
# vim: set shiftwidth=8 tabstop=8 autoindent noexpandtab copyindent:
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla's pageloader test
#
# The Initial Developer of the Original Code is the Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Vladimir Vukicevic <vladimir@pobox.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = layout
EXTRA_COMPONENTS= \
tp-cmdline.js \
tp-cmdline.manifest \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,81 +0,0 @@
Pageload Test Component
=======================
Usage:
./firefox -tp file:///path/to/manifest.txt [-tpargs...]
See ./firefox -help for other arguments.
Manifest file format
====================
Comments in the manifest file start with a #. Each line may be:
* a URL (absolute or relative to the manifest)
This URL is added to the list of tests.
* one or more flags, followed by whitespace, followed by a URL
The only flag supported currently is '%', which indicates that
a test will do its own timing. (See Self-timing Tests below.)
* "include" followed by whitespace, followed by a URL
Parse the given manifest file.
Self-timing Tests
=================
Most timing tests are interested in timing how long it takes the page
to load; that is, from the start of page loading until the 'load'
event is dispatched. By default, this is what the pageloader will
time. However, if a test URL has the % flag, the test is expected to
report its own timing. For this purpose, the pageloader will provide
a function named "tpRecordTime" in the test's global object that it
should call once it has performed whatever timing it wants to do.
The given value will be used as the timing result for this test.
Output format
=============
The result is a dump to stdout via dump() --
browser.dom.window.dump.enabled must be set to true in the profile. A
number of output formats can be specified via the -tpformat command
line option, currently 'js', 'text', and 'tinderbox' are supported.
Sample 'js' format output:
([({page:"1280x1024-PNG/index.html", value:133, stddev:20.049937655763422}),({page:"bugzilla.mozilla.org/index.html", value:233, stddev:36.66606060105176}),({page:"espn.go.com/index.html", value:117.6, stddev:1.2}),({page:"home.netscape.com/index.html", value:97.8, stddev:47.41898354035017}),])
Sample 'text' format output:
============================================================
Page mean stdd min max raw
0 1280x1024-PNG/index.html 133 20 121 297 297,173,122,121,124,125
1 bugzilla.mozilla.org/index.html 233 37 192 395 395,273,223,192,198,279
2 espn.go.com/index.html 118 1 116 254 254,117,116,119,119,117
3 home.netscape.com/index.html 98 47 3 124 3,121,120,124,124,121
============================================================
Sample 'tinderbox' format output:
__start_tp_report
_x_x_mozilla_page_load,778.5,NaN,NaN
_x_x_mozilla_page_load_details,avgmedian|778.5|average|766.75|minimum|NaN|maximum|NaN|stddev|NaN|0;file:///c:/proj/mozilla-cvs/perf/tp2/base/www.cnn.com/index.html;778.5;766.75;722;1027;1027;788;777;722;780|...
__end_tp_report
Note that the minimum, maximum, stddev are not calculated; they're
always reported as NaN. (They were the minimum and maximum values of
any sampled value, and the standard deviation across all sampled
values -- not very useful.)
TODO
====
* Command line option to choose whether to run with or without browser chrome. Currently runs without.
* Tinderbox-dropping style output
* better yet would be to teach tinderbox about JSON

Просмотреть файл

@ -1,6 +0,0 @@
pageloader.jar:
% content pageloader %content/
* content/quit.js (quit.js)
* content/pageloader.js (pageloader.js)
content/pageloader.xul (pageloader.xul)
* content/report.js (report.js)

Просмотреть файл

@ -1,441 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is tp.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Rob Helmer <rhelmer@mozilla.com>
* Vladimir Vukicevic <vladimir@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
var NUM_CYCLES = 5;
var pageFilterRegexp = null;
var reportFormat = "js";
var useBrowser = true;
var winWidth = 1024;
var winHeight = 768;
var doRenderTest = false;
var pages;
var pageIndex;
var start_time;
var cycle;
var report;
var renderReport;
var noisy = false;
var timeout = -1;
var timeoutEvent = -1;
var running = false;
var forceCC = true;
var content;
var TEST_DOES_OWN_TIMING = 1;
var browserWindow = null;
// the io service
var gIOS = null;
function plInit() {
if (running) {
return;
}
running = true;
cycle = 0;
try {
var args = window.arguments[0].wrappedJSObject;
var manifestURI = args.manifest;
var startIndex = 0;
var endIndex = -1;
if (args.startIndex) startIndex = parseInt(args.startIndex);
if (args.endIndex) endIndex = parseInt(args.endIndex);
if (args.numCycles) NUM_CYCLES = parseInt(args.numCycles);
if (args.format) reportFormat = args.format;
if (args.width) winWidth = parseInt(args.width);
if (args.height) winHeight = parseInt(args.height);
if (args.filter) pageFilterRegexp = new RegExp(args.filter);
if (args.noisy) noisy = true;
if (args.timeout) timeout = parseInt(args.timeout);
forceCC = !args.noForceCC;
doRenderTest = args.doRender;
if (forceCC &&
!window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.garbageCollect) {
forceCC = false;
}
gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
if (args.offline)
gIOS.offline = true;
var fileURI = gIOS.newURI(manifestURI, null, null);
pages = plLoadURLsFromURI(fileURI);
if (!pages) {
dumpLine('tp: could not load URLs, quitting');
plStop(true);
}
if (pages.length == 0) {
dumpLine('tp: no pages to test, quitting');
plStop(true);
}
if (startIndex < 0)
startIndex = 0;
if (endIndex == -1 || endIndex >= pages.length)
endIndex = pages.length-1;
if (startIndex > endIndex) {
dumpLine("tp: error: startIndex >= endIndex");
plStop(true);
}
pages = pages.slice(startIndex,endIndex+1);
var pageUrls = pages.map(function(p) { return p.url.spec.toString(); });
report = new Report(pageUrls);
if (doRenderTest)
renderReport = new Report(pageUrls);
pageIndex = 0;
if (args.useBrowserChrome) {
var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Ci.nsIWindowWatcher);
var blank = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
blank.data = "about:blank";
browserWindow = wwatch.openWindow
(null, "chrome://browser/content/", "_blank",
"chrome,dialog=no,width=" + winWidth + ",height=" + winHeight, blank);
// get our window out of the way
window.resizeTo(10,10);
var browserLoadFunc = function (ev) {
browserWindow.removeEventListener('load', browserLoadFunc, true);
// do this half a second after load, because we need to be
// able to resize the window and not have it get clobbered
// by the persisted values
setTimeout(function () {
browserWindow.resizeTo(winWidth, winHeight);
browserWindow.moveTo(0, 0);
browserWindow.focus();
content = browserWindow.getBrowser();
setTimeout(plLoadPage, 100);
}, 500);
};
browserWindow.addEventListener('load', browserLoadFunc, true);
} else {
window.resizeTo(winWidth, winHeight);
content = document.getElementById('contentPageloader');
setTimeout(plLoadPage, 250);
}
} catch(e) {
dumpLine(e);
plStop(true);
}
}
function plPageFlags() {
return pages[pageIndex].flags;
}
// load the current page, start timing
var removeLastAddedListener = null;
function plLoadPage() {
var pageName = pages[pageIndex].url.spec;
if (removeLastAddedListener)
removeLastAddedListener();
if (plPageFlags() & TEST_DOES_OWN_TIMING) {
// if the page does its own timing, use a capturing handler
// to make sure that we can set up the function for content to call
content.addEventListener('load', plLoadHandlerCapturing, true);
removeLastAddedListener = function() {
content.removeEventListener('load', plLoadHandlerCapturing, true);
};
} else {
// if the page doesn't do its own timing, use a bubbling handler
// to make sure that we're called after the page's own onload() handling
// XXX we use a capturing event here too -- load events don't bubble up
// to the <browser> element. See bug 390263.
content.addEventListener('load', plLoadHandler, true);
removeLastAddedListener = function() {
content.removeEventListener('load', plLoadHandler, true);
};
}
if (timeout > 0) {
timeoutEvent = setTimeout('loadFail()', timeout);
}
start_time = Date.now();
content.loadURI(pageName);
}
function loadFail() {
var pageName = pages[pageIndex].url.spec;
dumpLine("__FAILTimeout exceeded on " + pageName + "__FAIL")
plStop(true);
}
function plNextPage() {
if (pageIndex < pages.length-1) {
pageIndex++;
if (forceCC) {
var tccstart = new Date();
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.garbageCollect();
var tccend = new Date();
report.recordCCTime(tccend - tccstart);
}
setTimeout(plLoadPage, 250);
} else {
plStop(false);
}
}
function plRecordTime(time) {
var pageName = pages[pageIndex].url.spec;
var i = pageIndex
if (i < pages.length-1) {
i++;
} else {
i = 0;
}
var nextName = pages[i].url.spec;
report.recordTime(pageIndex, time);
if (noisy) {
dumpLine("Cycle " + (cycle+1) + ": loaded " + pageName + " (next: " + nextName + ")");
}
}
function plLoadHandlerCapturing(evt) {
// make sure we pick up the right load event
if (evt.type != 'load' ||
evt.originalTarget.defaultView.frameElement)
return;
if (timeout > 0) {
clearTimeout(timeoutEvent);
}
if (!(plPageFlags() & TEST_DOES_OWN_TIMING)) {
dumpLine("tp: Capturing onload handler used with page that doesn't do its own timing?");
plStop(true);
}
// set up the function for content to call
content.contentWindow.wrappedJSObject.tpRecordTime = function (time) {
plRecordTime(time);
setTimeout(plNextPage, 250);
};
}
// the onload handler
function plLoadHandler(evt) {
// make sure we pick up the right load event
if (evt.type != 'load' ||
evt.originalTarget.defaultView.frameElement)
return;
if (timeout > 0) {
clearTimeout(timeoutEvent);
}
var end_time = Date.now();
var time = (end_time - start_time);
// does this page want to do its own timing?
// if so, we shouldn't be here
if (plPageFlags() & TEST_DOES_OWN_TIMING) {
dumpLine("tp: Bubbling onload handler used with page that does its own timing?");
plStop(true);
}
plRecordTime(time);
if (doRenderTest)
runRenderTest();
plNextPage();
}
function runRenderTest() {
const redrawsPerSample = 500;
if (!Ci.nsIDOMWindowUtils)
return;
var win;
if (browserWindow)
win = content.contentWindow;
else
win = window;
var wu = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
var start = Date.now();
for (var j = 0; j < redrawsPerSample; j++)
wu.redraw();
var end = Date.now();
renderReport.recordTime(pageIndex, end - start);
}
function plStop(force) {
try {
if (force == false) {
pageIndex = 0;
if (cycle < NUM_CYCLES-1) {
cycle++;
setTimeout(plLoadPage, 250);
return;
}
var formats = reportFormat.split(",");
if (!renderReport) {
for each (var fmt in formats)
dumpLine(report.getReport(fmt));
}
else {
dumpLine ("*************** Render report *******************");
for each (var fmt in formats)
dumpLine(renderReport.getReport(fmt));
}
}
} catch (e) {
dumpLine(e);
}
if (content)
content.removeEventListener('load', plLoadHandler, true);
goQuitApplication();
}
/* Returns array */
function plLoadURLsFromURI(manifestUri) {
var fstream = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
var uriFile = manifestUri.QueryInterface(Ci.nsIFileURL);
fstream.init(uriFile.file, -1, 0, 0);
var lstream = fstream.QueryInterface(Ci.nsILineInputStream);
var d = [];
var lineNo = 0;
var line = {value:null};
var more;
do {
lineNo++;
more = lstream.readLine(line);
var s = line.value;
// strip comments
s = s.replace(/#.*/, '');
// strip leading and trailing whitespace
s = s.replace(/^\s*/, '').replace(/s\*$/, '');
if (!s)
continue;
var flags = 0;
var urlspec = s;
// split on whitespace, and figure out if we have any flags
var items = s.split(/\s+/);
if (items[0] == "include") {
if (items.length != 2) {
dumpLine("tp: Error on line " + lineNo + " in " + manifestUri.spec + ": include must be followed by the manifest to include!");
return null;
}
var subManifest = gIOS.newURI(items[1], null, manifestUri);
if (subManifest == null) {
dumpLine("tp: invalid URI on line " + manifestUri.spec + ":" + lineNo + " : '" + line.value + "'");
return null;
}
var subItems = plLoadURLsFromURI(subManifest);
if (subItems == null)
return null;
d = d.concat(subItems);
} else {
if (items.length == 2) {
if (items[0].indexOf("%") != -1)
flags |= TEST_DOES_OWN_TIMING;
urlspec = items[1];
} else if (items.length != 1) {
dumpLine("tp: Error on line " + lineNo + " in " + manifestUri.spec + ": whitespace must be %-escaped!");
return null;
}
var url = gIOS.newURI(urlspec, null, manifestUri);
if (pageFilterRegexp && !pageFilterRegexp.test(url.spec))
continue;
d.push({ url: url,
flags: flags });
}
} while (more);
return d;
}
function dumpLine(str) {
dump(str);
dump("\n");
}

Просмотреть файл

@ -1,57 +0,0 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (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.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is tp.
-
- The Initial Developer of the Original Code is the Mozilla Corporation.
- Portions created by the Initial Developer are Copyright (C) 2007
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Rob Helmer <rhelmer@mozilla.com>
- Vladimir Vukicevic <vladimir@mozilla.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="pageloader.css" type="text/css"?>
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="pageloader"
screenX="0" screenY="0"
onload="plInit()">
<script type="application/javascript"
src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="report.js"/>
<script type="application/javascript" src="pageloader.js"/>
<script type="application/javascript" src="quit.js"/>
<browser id="contentPageloader" src="about:blank"
type="content" flex="1"/>
</window>

Просмотреть файл

@ -1,110 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is The Original Code is Mozilla Automated Testing Code
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Bob Clary <bob@bclary.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
From mozilla/toolkit/content
These files did not have a license
*/
function canQuitApplication()
{
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
if (!os)
{
return true;
}
try
{
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
.createInstance(Components.interfaces.nsISupportsPRBool);
os.notifyObservers(cancelQuit, "quit-application-requested", null);
// Something aborted the quit process.
if (cancelQuit.data)
{
return false;
}
}
catch (ex)
{
}
return true;
}
function goQuitApplication()
{
if (!canQuitApplication())
{
return false;
}
const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
const kAppShell = '@mozilla.org/appshell/appShellService;1';
var appService;
var forceQuit;
if (kAppStartup in Components.classes)
{
appService = Components.classes[kAppStartup].
getService(Components.interfaces.nsIAppStartup);
forceQuit = Components.interfaces.nsIAppStartup.eForceQuit;
}
else if (kAppShell in Components.classes)
{
appService = Components.classes[kAppShell].
getService(Components.interfaces.nsIAppShellService);
forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
}
else
{
throw 'goQuitApplication: no AppStartup/appShell';
}
try
{
appService.quit(forceQuit);
}
catch(ex)
{
throw('goQuitApplication: ' + ex);
}
return true;
}

Просмотреть файл

@ -1,268 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is tp.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
* Rob Helmer <rhelmer@mozilla.com>
* Vladimir Vukicevic <vladimir@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// Constructor
function Report(pages) {
this.pages = pages;
this.timeVals = new Array(pages.length); // matrix of times
for (var i = 0; i < this.timeVals.length; ++i) {
this.timeVals[i] = new Array();
}
this.totalCCTime = 0;
this.showTotalCCTime = false;
}
// given an array of strings, finds the longest common prefix
function findCommonPrefixLength(strs) {
if (strs.length < 2)
return 0;
var len = 0;
do {
var newlen = len + 1;
var newprefix = null;
var failed = false;
for (var i = 0; i < strs.length; i++) {
if (newlen > strs[i].length) {
failed = true;
break;
}
var s = strs[i].substr(0, newlen);
if (newprefix == null) {
newprefix = s;
} else if (newprefix != s) {
failed = true;
break;
}
}
if (failed)
break;
len++;
} while (true);
return len;
}
function compareNumbers(a, b) {
return a - b;
}
// returns an object with the following properties:
// min : min value of array elements
// max : max value of array elements
// mean : mean value of array elements
// vari : variance computation
// stdd : standard deviation, sqrt(vari)
// indexOfMax : index of max element (the element that is
// removed from the mean computation)
function getArrayStats(ary) {
var r = {};
r.min = ary[0];
r.max = ary[0];
r.indexOfMax = 0;
var sum = 0;
for (var i = 0; i < ary.length; ++i) {
if (ary[i] < r.min) {
r.min = ary[i];
} else if (ary[i] > r.max) {
r.max = ary[i];
r.indexOfMax = i;
}
sum = sum + ary[i];
}
// median
if (ary.length > 1) {
sorted_ary = ary.concat();
sorted_ary.sort(compareNumbers);
// remove longest run
sorted_ary.pop();
if (sorted_ary.length%2) {
r.median = sorted_ary[(sorted_ary.length-1)/2];
}else{
var n = Math.floor(sorted_ary.length / 2);
if (n >= sorted_ary.length)
r.median = sorted_ary[n];
else
r.median = (sorted_ary[n-1] + sorted_ary[n]) / 2;
}
}else{
r.median = ary[0];
}
// ignore max value when computing mean and stddev
if (ary.length > 1)
r.mean = (sum - r.max) / (ary.length - 1);
else
r.mean = ary[0];
r.vari = 0;
for (var i = 0; i < ary.length; ++i) {
if (i == r.indexOfMax)
continue;
var d = r.mean - ary[i];
r.vari = r.vari + d * d;
}
if (ary.length > 1) {
r.vari = r.vari / (ary.length - 1);
r.stdd = Math.sqrt(r.vari);
} else {
r.vari = 0.0;
r.stdd = 0.0;
}
return r;
}
function strPad(o, len, left) {
var str = o.toString();
if (!len)
len = 6;
if (left == null)
left = true;
if (str.length < len) {
len -= str.length;
while (--len) {
if (left)
str = " " + str;
else
str += " ";
}
}
str += " ";
return str;
}
function strPadFixed(n, len, left) {
return strPad(n.toFixed(0), len, left);
}
Report.prototype.getReport = function(format) {
// avg and avg median are cumulative for all the pages
var avgs = new Array();
var medians = new Array();
for (var i = 0; i < this.timeVals.length; ++i) {
avgs[i] = getArrayStats(this.timeVals[i]).mean;
medians[i] = getArrayStats(this.timeVals[i]).median;
}
var avg = getArrayStats(avgs).mean;
var avgmed = getArrayStats(medians).mean;
var report;
var prefixLen = findCommonPrefixLength(this.pages);
if (format == "js") {
// output "simple" js format;
// array of { page: "str", value: 123.4, stddev: 23.3 } objects
report = "([";
for (var i = 0; i < this.timeVals.length; i++) {
var stats = getArrayStats(this.timeVals[i]);
report += uneval({ page: this.pages[i].substr(prefixLen), value: stats.mean, stddev: stats.stdd});
report += ",";
}
report += "])";
} else if (format == "jsfull") {
// output "full" js format, with raw values
} else if (format == "text") {
// output text format suitable for dumping
report = "============================================================\n";
report += " " + strPad("Page", 40, false) + strPad("mean") + strPad("stdd") + strPad("min") + strPad("max") + "raw" + "\n";
for (var i = 0; i < this.timeVals.length; i++) {
var stats = getArrayStats(this.timeVals[i]);
report +=
strPad(i, 4, true) +
strPad(this.pages[i].substr(prefixLen), 40, false) +
strPadFixed(stats.mean) +
strPadFixed(stats.stdd) +
strPadFixed(stats.min) +
strPadFixed(stats.max) +
this.timeVals[i] +
"\n";
}
if (this.showTotalCCTime) {
report += "Cycle collection: " + this.totalCCTime + "\n"
}
report += "============================================================\n";
} else if (format == "tinderbox") {
report = "__start_tp_report\n";
report += "_x_x_mozilla_page_load,"+avgmed+",NaN,NaN\n"; // max and min are just 0, ignored
report += "_x_x_mozilla_page_load_details,avgmedian|"+avgmed+"|average|"+avg.toFixed(2)+"|minimum|NaN|maximum|NaN|stddev|NaN\n";
report += "|i|pagename|median|mean|min|max|runs|\n";
for (var i = 0; i < this.timeVals.length; i++) {
var r = getArrayStats(this.timeVals[i]);
report += '|'+
i + ';'+
this.pages[i].substr(prefixLen) + ';'+
r.median + ';'+
r.mean + ';'+
r.min + ';'+
r.max + ';'+
this.timeVals[i].join(";") +
"\n";
}
report += "__end_tp_report\n";
if (this.showTotalCCTime) {
report += "__start_cc_report\n";
report += "_x_x_mozilla_cycle_collect," + this.totalCCTime + "\n";
report += "__end_cc_report\n";
}
var now = (new Date()).getTime();
report += "__startTimestamp" + now + "__endTimestamp\n"; //timestamp for determning shutdown time, used by talos
} else {
report = "Unknown report format";
}
return report;
}
Report.prototype.recordTime = function(pageIndex, ms) {
this.timeVals[pageIndex].push(ms);
}
Report.prototype.recordCCTime = function(ms) {
this.totalCCTime += ms;
this.showTotalCCTime = true;
}

Просмотреть файл

@ -1,119 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is DOM Inspector.
*
* The Initial Developer of the Original Code is
* Christopher A. Aillon <christopher@aillon.com>.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher A. Aillon <christopher@aillon.com>
* L. David Baron, Mozilla Corporation <dbaron@dbaron.org> (modified for reftest)
* Vladimir Vukicevic, Mozilla Corporation <dbaron@dbaron.org> (modified for tp)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
// This only implements nsICommandLineHandler, since it needs
// to handle multiple arguments.
const nsISupports = Components.interfaces.nsISupports;
const nsICommandLine = Components.interfaces.nsICommandLine;
const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler;
const nsISupportsString = Components.interfaces.nsISupportsString;
const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
function PageLoaderCmdLineHandler() {}
PageLoaderCmdLineHandler.prototype =
{
classID: Components.ID('{8AF052F5-8EFE-4359-8266-E16498A82E8B}'),
/* nsISupports */
QueryInterface : XPCOMUtils.generateQI([nsICommandLineHandler]),
/* nsICommandLineHandler */
handle : function handler_handle(cmdLine) {
var args = {};
try {
var uristr = cmdLine.handleFlagWithParam("tp", false);
if (uristr == null)
return;
try {
args.manifest = cmdLine.resolveURI(uristr).spec;
} catch (e) {
return;
}
args.numCycles = cmdLine.handleFlagWithParam("tpcycles", false);
args.startIndex = cmdLine.handleFlagWithParam("tpstart", false);
args.endIndex = cmdLine.handleFlagWithParam("tpend", false);
args.filter = cmdLine.handleFlagWithParam("tpfilter", false);
args.format = cmdLine.handleFlagWithParam("tpformat", false);
args.useBrowserChrome = cmdLine.handleFlag("tpchrome", false);
args.doRender = cmdLine.handleFlag("tprender", false);
args.width = cmdLine.handleFlagWithParam("tpwidth", false);
args.height = cmdLine.handleFlagWithParam("tpheight", false);
args.offline = cmdLine.handleFlag("tpoffline", false);
args.noisy = cmdLine.handleFlag("tpnoisy", false);
args.timeout = cmdLine.handleFlagWithParam("tptimeout", false);
args.noForceCC = cmdLine.handleFlag("tpnoforcecc", false);
}
catch (e) {
return;
}
// get our data through xpconnect
args.wrappedJSObject = args;
var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(nsIWindowWatcher);
wwatch.openWindow(null, "chrome://pageloader/content/pageloader.xul", "_blank",
"chrome,dialog=no,all", args);
cmdLine.preventDefault = true;
},
helpInfo :
" -tp <file> Run pageload perf tests on given manifest\n" +
" -tpfilter str Only include pages from manifest that contain str (regexp)\n" +
" -tpcycles n Loop through pages n times\n" +
" -tpstart n Start at index n in the manifest\n" +
" -tpend n End with index n in the manifest\n" +
" -tpformat f1,f2,.. Report format(s) to use\n" +
" -tpchrome Test with normal browser chrome\n" +
" -tprender Run render-only benchmark for each page\n" +
" -tpwidth width Width of window\n" +
" -tpheight height Height of window\n" +
" -tpoffline Force offline mode\n" +
" -tpnoisy Dump the name of the last loaded page to console\n" +
" -tptimeout Max amount of time given for a page to load, quit if exceeded\n" +
" -tpnoforcecc Don't force cycle collection between each pageload\n"
};
var NSGetFactory = XPCOMUtils.generateNSGetFactory([PageLoaderCmdLineHandler]);

Просмотреть файл

@ -1,3 +0,0 @@
component {8AF052F5-8EFE-4359-8266-E16498A82E8B} tp-cmdline.js
contract @mozilla.org/commandlinehandler/general-startup;1?type=tp {8AF052F5-8EFE-4359-8266-E16498A82E8B}
category command-line-handler m-tp @mozilla.org/commandlinehandler/general-startup;1?type=tp

Просмотреть файл

@ -1,6 +0,0 @@
all:
zip -r pageloader.xpi chrome chrome.manifest install.rdf
check:
./test/chrome/content/report.js
./test/chrome/content/pageloader.js

Просмотреть файл

@ -1,13 +0,0 @@
This is a pageloader extension for Firefox. It cycles through a list of URLs
specified in a text file by the user (one URL per line), and reports statistics
and raw data about the time each page took to load.
This data is dumped to the console, so the browser.dom.window.dump.enabled pref
(boolean) must be set to "true", and on Windows Firefox must be run with the
"-console" command line switch.
This test is intended to be run standalone from a chrome URL, e.g.:
firefox -chrome chrome://pageloader/content/pageloader.xul
The window will close and the data will be dumped to the console when the
test has completed.

Просмотреть файл

@ -1 +0,0 @@
content pageloader chrome/content/

Просмотреть файл

@ -1,3 +0,0 @@
window {
background-color: #0088CC;
}

Просмотреть файл

@ -1,199 +0,0 @@
var NUM_CYCLES = 5;
var pages;
var pageIndex;
var results;
var start_time;
var end_time;
var cycle;
var report;
var running = false;
function plInit() {
if (running) {
return;
}
running = true;
try {
pageIndex = 0;
cycle = 0;
results = new Object();
if (! pages) {
var file;
try {
file = plDefaultFile();
} catch(e) {
dumpLine(e);
}
if (! file.exists()) {
try {
file = plFilePicker();
} catch(e) {
dumpLine(e);
}
}
pages = plLoadURLsFromFile(file);
}
if (! pages ) {
alert('could not load URLs, quitting');
plStop(true);
}
if (pages.length == 0) {
alert('no pages to test, quitting');
plStop(true);
}
report = new Report(pages);
plLoadPage();
} catch(e) {
dumpLine(e);
plStop(true);
}
}
function plLoadPage() {
try {
start_time = new Date();
p = pages[pageIndex];
this.content = document.getElementById('contentPageloader');
this.content.addEventListener('load', plLoadHandler, true);
this.content.loadURI(p);
} catch (e) {
dumpLine(e);
plStop(true);
}
}
function plLoadHandler(evt) {
if (evt.type == 'load') {
window.setTimeout('reallyHandle()', 500);
} else {
dumpLine('Unknown event type: '+evt.type);
plStop(true);
}
}
function reallyHandle() {
if (pageIndex < pages.length) {
try {
end_time = new Date();
var pageName = pages[pageIndex];
results[pageName] = (end_time - start_time);
start_time = new Date();
dumpLine(pageName+" took "+results[pageName]);
plReport();
pageIndex++;
plLoadPage();
} catch(e) {
dumpLine(e);
plStop(true);
}
} else {
plStop(false);
}
}
function plReport() {
try {
var reportNode = document.getElementById('report');
var pageName = pages[pageIndex];
var time = results[pageName];
report.recordTime(pageIndex, time);
} catch(e) {
dumpLine(e);
plStop(false);
}
}
function plStop(force) {
try {
if (force == false) {
pageIndex = 0;
results = new Object;
if (cycle < NUM_CYCLES) {
cycle++;
plLoadPage();
return;
} else {
dumpLine(report.getReport());
}
}
this.content.removeEventListener('load', plLoadHandler, true);
} catch(e) {
dumpLine(e);
}
goQuitApplication();
}
/* Returns nsilocalfile */
function plDefaultFile() {
try {
const nsIIOService = Components.interfaces.nsIIOService;
var dirService =
Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties);
var profileDir = dirService.get("ProfD",
Components.interfaces.nsILocalFile);
var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
var path = profileDir.path;
file.initWithPath(path);
file.append("urls.txt");
dumpLine('will attempt to load default file '+file.path);
return file;
} catch (e) {
dumpLine(e);
}
}
/* Returns nsifile */
function plFilePicker() {
try {
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, "Dialog Title", nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
var rv = fp.show();
if (rv == nsIFilePicker.returnOK) {
return fp.file;
}
} catch (e) {
dumpLine(e);
}
}
/* Returns array */
function plLoadURLsFromFile(file) {
try {
var data = "";
var fstream =
Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance(Components.interfaces.nsIFileInputStream);
var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(Components.interfaces.nsIScriptableInputStream);
fstream.init(file, -1, 0, 0);
sstream.init(fstream);
var str = sstream.read(4096);
while (str.length > 0) {
data += str;
str = sstream.read(4096);
}
sstream.close();
fstream.close();
var p = data.split("\n");
// discard result of final split (EOF)
p.pop()
return p;
} catch (e) {
dumpLine(e);
}
}
function dumpLine(str) {
dump(str);
dump("\n");
}

Просмотреть файл

@ -1,13 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="pageloader.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="plInit()">
<script type="application/x-javascript"
src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="report.js"></script>
<script type="application/x-javascript" src="pageloader.js"></script>
<box align="center">
<browser id="contentPageloader" src="about:blank"
type="content" flex="1" align="center" width="1024" height="768"/>
</box>
</window>

Просмотреть файл

@ -1,112 +0,0 @@
// Constructor
function Report(pages) {
this.pages = pages;
this.timeVals = new Array(pages.length); // matrix of times
for (var i = 0; i < this.timeVals.length; ++i) {
this.timeVals[i] = new Array;
}
}
// returns an object with the following properties:
// min : min value of array elements
// max : max value of array elements
// mean : mean value of array elements
// vari : variance computation
// stdd : standard deviation, sqrt(vari)
// indexOfMax : index of max element (the element that is
// removed from the mean computation)
Report.prototype.getArrayStats = function(ary) {
var r = {};
r.min = ary[0];
r.max = ary[0];
r.indexOfMax = 0;
var sum = 0;
for (var i = 0; i < ary.length; ++i) {
if (ary[i] < r.min) {
r.min = ary[i];
} else if (ary[i] > r.max) {
r.max = ary[i];
r.indexOfMax = i;
}
sum = sum + ary[i];
}
// median
sorted_ary = ary.concat();
sorted_ary.sort();
// remove longest run
sorted_ary.pop();
if (sorted_ary.length%2) {
r.median = sorted_ary[(sorted_ary.length-1)/2];
}else{
var n = Math.floor(sorted_ary.length / 2);
r.median = (sorted_ary[n] + sorted_ary[n + 1]) / 2;
}
// ignore max value when computing mean and stddev
r.mean = (sum - r.max) / (ary.length - 1);
r.vari = 0;
for (var i = 0; i < ary.length; ++i) {
if (i == r.indexOfMax)
continue;
var d = r.mean - ary[i];
r.vari = r.vari + d * d;
}
r.vari = r.vari / (ary.length - 1);
r.stdd = Math.sqrt(r.vari);
return r;
}
Report.prototype.getReport = function() {
var all = new Array();
var counter = 0;
for (var i = 0; i < this.timeVals.length; ++i) {
for (var j = 0; j < this.timeVals[i].length; ++j) {
all[counter] = this.timeVals[i][j];
++counter;
}
}
// avg and avg median are cumulative for all the pages
var avgs = new Array();
var medians = new Array();
for (var i = 0; i < this.timeVals.length; ++i) {
avgs[i] = this.getArrayStats(this.timeVals[i]).mean;
medians[i] = this.getArrayStats(this.timeVals[i]).median;
}
var avg = this.getArrayStats(avgs).mean;
var avgmed = this.getArrayStats(medians).mean;
var r = this.getArrayStats(all);
var report = '';
report +=
"(tinderbox dropping follows)\n"+
"_x_x_mozilla_page_load,"+avgmed+","+r.max+","+r.min+"\n"+
"_x_x_mozilla_page_load_details,avgmedian|"+avgmed+"|average|"+avg.toFixed(2)+"|minimum|"+r.min+"|maximum|"+r.max+"|stddev|"+r.stdd.toFixed(2)+":"
for (var i = 0; i < this.timeVals.length; ++i) {
r = this.getArrayStats(this.timeVals[i]);
report +=
'|'+
i+';'+
pages[i]+';'+
r.median+';'+
r.mean+';'+
r.min+';'+
r.max
for (var j = 0; j < this.timeVals[i].length; ++j) {
report +=
';'+this.timeVals[i][j]
}
}
return report;
}
Report.prototype.recordTime = function(pageIndex, ms) {
this.timeVals[pageIndex].push(ms);
}

Просмотреть файл

@ -1,27 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>pageloader@mozilla.org</em:id>
<em:version>0.5</em:version>
<em:type>2</em:type>
<!-- Target Application this extension can install into,
with minimum and maximum supported versions. -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.0+</em:minVersion>
<em:maxVersion>4.0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>PageLoader</em:name>
<em:description>A pageloader extension.</em:description>
<em:creator>Robert Helmer</em:creator>
<em:homepageURL>http://www.roberthelmer.com/</em:homepageURL>
</Description>
</RDF>

Просмотреть файл

@ -1,46 +0,0 @@
#!/usr/bin/js
// mock objects
function alert(str) {
print(str);
}
function dump(str) {
print(str);
}
window = new Object();
document = new Object();
document.createEvent = function(str) {
obj = new Object();
obj.initMouseEvent = function() {}
return obj;
}
document.getElementById = function(str) {
obj = new Object();
if (str == 'contentPageloader') {
obj.content = new Object();
obj.content.addEventListener = function() {}
obj.content.removeEventListener = function() {}
obj.content.loadURI = function() {}
return obj.content;
} else if (str == 'plStartButton') {
obj.startButton = new Object();
obj.startButton.setAttribute = function(key, value) {}
return obj.startButton;
}
}
evt = new Object();
evt.type = 'load';
window.setTimeout = function() {}
this.content = document.getElementById('content');
// dummy data
pages = ['http://google.com'];
load(['chrome/content/pageloader.js']);
load(['chrome/content/report.js']);
plInit(true);
plInit(false);
for (cycle = 0; cycle < NUM_CYCLES*2; cycle++) {
plLoadHandler(evt);
}

Просмотреть файл

@ -1,19 +0,0 @@
#!/usr/bin/js
load(['chrome/content/report.js']);
pages = [
'http://www.google.com',
'http://www.yahoo.com',
'http://www.msn.com',
];
cycle_time = 5;
report = new Report(pages);
for (var c=0; c < cycle_time; c++) {
for (var p=0; p < pages.length; p++) {
report.recordTime(p, c+1);
}
}
print(report.getReport());

Просмотреть файл

@ -834,7 +834,6 @@ if [ "$ENABLE_TESTS" ]; then
layout/style/test/Makefile
layout/style/test/chrome/Makefile
layout/tables/test/Makefile
layout/tools/pageloader/Makefile
layout/tools/reftest/Makefile
layout/xul/base/test/Makefile
layout/xul/test/Makefile