2015-02-03 20:30:51 +03:00
|
|
|
var Benchmark = (function() {
|
|
|
|
|
|
|
|
function mean(array) {
|
|
|
|
function add(a, b) {
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
return array.reduce(add, 0) / array.length;
|
|
|
|
}
|
|
|
|
|
2015-02-10 05:53:43 +03:00
|
|
|
var defaultStorage = {
|
2015-03-28 04:29:58 +03:00
|
|
|
// 30 is usually considered a large enough sample size for the central limit theorem
|
|
|
|
// to take effect, unless the distribution is too weird
|
|
|
|
numRounds: 30,
|
2015-02-10 02:54:20 +03:00
|
|
|
roundDelay: 5000, // ms to delay starting next round of tests
|
2015-03-13 02:37:57 +03:00
|
|
|
baseline: {},
|
|
|
|
current: {},
|
2015-02-10 05:53:43 +03:00
|
|
|
running: false,
|
|
|
|
round: 0,
|
2015-03-13 02:37:57 +03:00
|
|
|
deleteFs: false,
|
|
|
|
deleteJitCache: false,
|
|
|
|
buildBaseline: false,
|
|
|
|
recordMemory: true
|
2015-02-10 05:53:43 +03:00
|
|
|
};
|
|
|
|
|
2015-03-13 02:37:57 +03:00
|
|
|
var NO_SECURITY = typeof netscape !== "undefined" && netscape.security.PrivilegeManager;
|
|
|
|
|
|
|
|
function enableSuperPowers() {
|
2015-03-27 03:37:24 +03:00
|
|
|
// To enable chrome privileges use a separate profile and set the pref
|
2015-03-13 02:37:57 +03:00
|
|
|
// security.turn_off_all_security_so_that_viruses_can_take_over_this_computer
|
2015-03-27 03:37:24 +03:00
|
|
|
// to boolean true. To do this on a device, see:
|
|
|
|
// https://wiki.mozilla.org/B2G/QA/Tips_And_Tricks#For_changing_the_preference:
|
2015-03-13 02:37:57 +03:00
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
}
|
|
|
|
|
|
|
|
function forceCollectors() {
|
2015-03-25 22:02:21 +03:00
|
|
|
if (!NO_SECURITY) {
|
|
|
|
return Promise.resolve();
|
2015-02-10 05:53:43 +03:00
|
|
|
}
|
2015-03-25 22:02:21 +03:00
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
enableSuperPowers();
|
|
|
|
console.log("Starting minimize memory.");
|
|
|
|
var gMgr = Components.classes["@mozilla.org/memory-reporter-manager;1"].getService(Components.interfaces.nsIMemoryReporterManager);
|
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
|
|
|
Services.obs.notifyObservers(null, "child-mmu-request", null);
|
|
|
|
gMgr.minimizeMemoryUsage(function() {
|
|
|
|
console.log("Finished minimize memory.");
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
2015-02-10 05:53:43 +03:00
|
|
|
}
|
|
|
|
|
2015-03-13 02:37:57 +03:00
|
|
|
var STORAGE_KEY = "benchmark";
|
|
|
|
var storage;
|
|
|
|
function initStorage(defaults) {
|
|
|
|
if (!(STORAGE_KEY in localStorage)) {
|
|
|
|
storage = defaults;
|
|
|
|
} else {
|
|
|
|
storage = JSON.parse(localStorage[STORAGE_KEY]);
|
|
|
|
for (var key in defaults) {
|
|
|
|
if (key in storage) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
storage[key] = defaults[key];
|
|
|
|
}
|
2015-02-10 05:53:43 +03:00
|
|
|
}
|
2015-03-13 02:37:57 +03:00
|
|
|
}
|
2015-02-10 05:53:43 +03:00
|
|
|
|
2015-03-13 02:37:57 +03:00
|
|
|
function saveStorage() {
|
|
|
|
localStorage[STORAGE_KEY] = JSON.stringify(storage);
|
|
|
|
}
|
|
|
|
|
|
|
|
initStorage(defaultStorage);
|
|
|
|
var LEFT = 0; var CENTER = 1; var RIGHT = 2;
|
|
|
|
function prettyTable(rows, alignment) {
|
|
|
|
function pad(str, repeat, n, align) {
|
|
|
|
if (align === LEFT) {
|
|
|
|
return str.padRight(repeat, n);
|
|
|
|
} else if (align === CENTER) {
|
|
|
|
var middle = ((n - str.length) / 2) | 0;
|
|
|
|
return str.padRight(repeat, middle + str.length).padLeft(repeat, n);
|
|
|
|
} else if (align === RIGHT) {
|
|
|
|
return str.padLeft(repeat, n);
|
|
|
|
}
|
|
|
|
throw new Error("Bad align value." + align);
|
|
|
|
}
|
|
|
|
var maxColumnLengths = [];
|
|
|
|
var numColumns = rows[0].length;
|
|
|
|
for (var colIndex = 0; colIndex < numColumns; colIndex++) {
|
|
|
|
var maxLength = 0;
|
|
|
|
for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
2015-04-28 15:08:31 +03:00
|
|
|
var strLen = rows[rowIndex][colIndex].toString().length;
|
|
|
|
if (rows[rowIndex].untrusted) {
|
|
|
|
strLen += 2;
|
|
|
|
}
|
|
|
|
maxLength = Math.max(strLen, maxLength);
|
2015-03-13 02:37:57 +03:00
|
|
|
}
|
|
|
|
maxColumnLengths[colIndex] = maxLength;
|
|
|
|
}
|
|
|
|
var out = "";
|
|
|
|
for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
|
|
out += "| ";
|
|
|
|
for (var colIndex = 0; colIndex < numColumns; colIndex++) {
|
2015-04-28 15:08:31 +03:00
|
|
|
var str = rows[rowIndex][colIndex].toString();
|
|
|
|
if (rows[rowIndex].untrusted) {
|
|
|
|
str = "*" + str + "*";
|
|
|
|
}
|
|
|
|
out += pad(str, " ", maxColumnLengths[colIndex], rowIndex === 0 ? CENTER : alignment[colIndex]) + " | ";
|
2015-03-13 02:37:57 +03:00
|
|
|
}
|
|
|
|
out += "\n";
|
|
|
|
if (rowIndex === 0) {
|
|
|
|
out += "|";
|
|
|
|
for (var colIndex = 0; colIndex < numColumns; colIndex++) {
|
|
|
|
var align = alignment[colIndex];
|
|
|
|
if (align === 0) {
|
|
|
|
out += ":".padRight("-", maxColumnLengths[colIndex] + 2);
|
|
|
|
} else if (align === 1) {
|
|
|
|
out += ":".padLeft("-", maxColumnLengths[colIndex] + 1) + ":";
|
|
|
|
} else if (align === 2) {
|
|
|
|
out += ":".padLeft("-", maxColumnLengths[colIndex] + 2);
|
|
|
|
}
|
|
|
|
out += "|";
|
|
|
|
}
|
|
|
|
out += "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
function numberWithCommas(x) {
|
|
|
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
|
|
}
|
|
|
|
|
|
|
|
function msFormatter(x) {
|
|
|
|
return numberWithCommas(Math.round(x)) + "ms";
|
|
|
|
}
|
|
|
|
|
|
|
|
function byteFormatter(x) {
|
|
|
|
return numberWithCommas(Math.round(x / 1024)) + "kb";
|
|
|
|
}
|
|
|
|
|
|
|
|
var valueFormatters = {
|
2015-04-22 23:52:06 +03:00
|
|
|
startupTime: msFormatter,
|
2015-04-22 01:20:48 +03:00
|
|
|
vmStartupTime: msFormatter,
|
2015-04-22 23:52:06 +03:00
|
|
|
bgStartupTime: msFormatter,
|
|
|
|
fgStartupTime: msFormatter,
|
2015-03-13 02:37:57 +03:00
|
|
|
totalSize: byteFormatter,
|
|
|
|
domSize: byteFormatter,
|
|
|
|
styleSize: byteFormatter,
|
|
|
|
jsObjectsSize: byteFormatter,
|
|
|
|
jsStringsSize: byteFormatter,
|
|
|
|
jsOtherSize: byteFormatter,
|
|
|
|
otherSize: byteFormatter,
|
2015-04-25 14:47:32 +03:00
|
|
|
USS: byteFormatter,
|
|
|
|
peakRSS: byteFormatter,
|
2015-03-13 02:37:57 +03:00
|
|
|
};
|
2015-02-10 05:53:43 +03:00
|
|
|
|
2015-04-28 15:08:31 +03:00
|
|
|
var untrustedValues = [
|
|
|
|
"totalSize", "domSize", "styleSize", "jsObjectsSize",
|
|
|
|
"jsStringsSize", "jsOtherSize", "otherSize", "USS",
|
|
|
|
"peakRSS",
|
|
|
|
];
|
|
|
|
|
2015-03-24 21:25:43 +03:00
|
|
|
function sampleMemory() {
|
2015-03-25 22:02:21 +03:00
|
|
|
if (!NO_SECURITY) {
|
|
|
|
return Promise.resolve({});
|
|
|
|
}
|
|
|
|
return forceCollectors().then(function() {
|
2015-03-24 21:25:43 +03:00
|
|
|
var memoryReporter = Components.classes["@mozilla.org/memory-reporter-manager;1"].getService(Components.interfaces.nsIMemoryReporterManager);
|
|
|
|
|
|
|
|
var jsObjectsSize = {};
|
|
|
|
var jsStringsSize = {};
|
|
|
|
var jsOtherSize = {};
|
|
|
|
var domSize = {};
|
|
|
|
var styleSize = {};
|
|
|
|
var otherSize = {};
|
|
|
|
var totalSize = {};
|
|
|
|
var jsMilliseconds = {};
|
|
|
|
var nonJSMilliseconds = {};
|
|
|
|
|
|
|
|
try {
|
|
|
|
memoryReporter.sizeOfTab(window.parent.window, jsObjectsSize, jsStringsSize, jsOtherSize,
|
|
|
|
domSize, styleSize, otherSize, totalSize, jsMilliseconds, nonJSMilliseconds);
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
|
2015-04-29 03:04:51 +03:00
|
|
|
var memValues = {
|
2015-03-24 21:25:43 +03:00
|
|
|
totalSize: totalSize.value,
|
|
|
|
domSize: domSize.value,
|
|
|
|
styleSize: styleSize.value,
|
|
|
|
jsObjectsSize: jsObjectsSize.value,
|
|
|
|
jsStringsSize: jsStringsSize.value,
|
|
|
|
jsOtherSize: jsOtherSize.value,
|
|
|
|
otherSize: otherSize.value,
|
|
|
|
};
|
2015-04-29 03:04:51 +03:00
|
|
|
|
|
|
|
// residentUnique is not available on all platforms.
|
|
|
|
try {
|
|
|
|
memValues.USS = memoryReporter.residentUnique;
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// residentPeak is not available on all platforms.
|
|
|
|
try {
|
|
|
|
memValues.peakRSS = memoryReporter.residentPeak;
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
return memValues;
|
2015-03-25 22:02:21 +03:00
|
|
|
});
|
2015-03-24 21:25:43 +03:00
|
|
|
}
|
|
|
|
|
2015-02-10 05:53:43 +03:00
|
|
|
var startup = {
|
|
|
|
run: function(settings) {
|
|
|
|
storage.round = 0;
|
2015-03-13 02:37:57 +03:00
|
|
|
var current = storage.current = {};
|
2015-04-22 23:52:06 +03:00
|
|
|
current.startupTime = [];
|
2015-04-22 01:20:48 +03:00
|
|
|
current.vmStartupTime = [];
|
2015-04-22 23:52:06 +03:00
|
|
|
current.bgStartupTime = [];
|
|
|
|
current.fgStartupTime = [];
|
2015-03-13 02:37:57 +03:00
|
|
|
if (settings.recordMemory) {
|
|
|
|
storage.recordMemory = true;
|
|
|
|
current.totalSize = [];
|
|
|
|
current.domSize = [];
|
|
|
|
current.styleSize = [];
|
|
|
|
current.jsObjectsSize = [];
|
|
|
|
current.jsStringsSize = [];
|
|
|
|
current.jsOtherSize = [];
|
|
|
|
current.otherSize = [];
|
2015-04-25 14:47:32 +03:00
|
|
|
current.USS = [];
|
|
|
|
current.peakRSS = [];
|
2015-03-13 02:37:57 +03:00
|
|
|
}
|
2015-02-10 05:53:43 +03:00
|
|
|
storage.running = true;
|
|
|
|
storage.numRounds = "numRounds" in settings ? settings.numRounds : defaultStorage.numRounds;
|
|
|
|
storage.roundDelay = "roundDelay" in settings ? settings.roundDelay : defaultStorage.roundDelay;
|
|
|
|
storage.deleteFs = "deleteFs" in settings ? settings.deleteFs : defaultStorage.deleteFs;
|
|
|
|
storage.deleteJitCache = "deleteJitCache" in settings ? settings.deleteJitCache : defaultStorage.deleteJitCache;
|
|
|
|
storage.buildBaseline = "buildBaseline" in settings ? settings.buildBaseline : defaultStorage.buildBaseline;
|
|
|
|
if (storage.buildBaseline) {
|
2015-03-13 02:37:57 +03:00
|
|
|
storage.baseline = {};
|
2015-02-10 05:53:43 +03:00
|
|
|
}
|
2015-03-13 02:37:57 +03:00
|
|
|
saveStorage();
|
2015-02-10 02:54:20 +03:00
|
|
|
this.runNextRound();
|
2015-02-03 20:30:51 +03:00
|
|
|
},
|
2015-04-22 23:49:10 +03:00
|
|
|
startTimer: function(which, now) {
|
2015-02-10 05:53:43 +03:00
|
|
|
if (!storage.running) {
|
2015-02-03 20:30:51 +03:00
|
|
|
console.log("startTimer called while benchmark not running");
|
|
|
|
return;
|
|
|
|
}
|
2015-04-22 01:20:48 +03:00
|
|
|
if (!this.startTime) {
|
|
|
|
this.startTime = {};
|
|
|
|
}
|
2015-04-22 23:49:10 +03:00
|
|
|
this.startTime[which] = now;
|
2015-02-03 20:30:51 +03:00
|
|
|
},
|
2015-04-22 23:49:10 +03:00
|
|
|
stopTimer: function(which, now) {
|
2015-02-10 05:53:43 +03:00
|
|
|
if (!storage.running) {
|
2015-02-03 20:30:51 +03:00
|
|
|
console.log("stopTimer called while benchmark not running");
|
|
|
|
return;
|
|
|
|
}
|
2015-04-22 01:20:48 +03:00
|
|
|
if (this.startTime[which] === null) {
|
2015-02-03 20:30:51 +03:00
|
|
|
console.log("stopTimer called without previous call to startTimer");
|
|
|
|
return;
|
|
|
|
}
|
2015-04-22 23:49:10 +03:00
|
|
|
var took = now - this.startTime[which];
|
2015-04-22 01:20:48 +03:00
|
|
|
storage.current[which].push(took);
|
2015-04-22 23:52:06 +03:00
|
|
|
if (which === "startupTime") {
|
2015-04-22 01:20:48 +03:00
|
|
|
storage.round++;
|
|
|
|
saveStorage();
|
|
|
|
this.runNextRound();
|
|
|
|
}
|
2015-03-17 03:26:29 +03:00
|
|
|
},
|
2015-03-24 21:25:43 +03:00
|
|
|
sampleMemoryToStorage: function() {
|
2015-03-25 22:02:21 +03:00
|
|
|
return sampleMemory().then(function(mem) {
|
|
|
|
for (var p in mem) {
|
|
|
|
storage.current[p].push(mem[p]);
|
|
|
|
}
|
|
|
|
saveStorage();
|
|
|
|
});
|
2015-02-03 20:30:51 +03:00
|
|
|
},
|
2015-02-10 02:54:20 +03:00
|
|
|
runNextRound: function() {
|
2015-03-17 03:26:29 +03:00
|
|
|
var self = this;
|
|
|
|
var done = storage.round >= storage.numRounds;
|
2015-02-03 20:30:51 +03:00
|
|
|
function run() {
|
2015-03-25 22:02:21 +03:00
|
|
|
var promise;
|
|
|
|
if (storage.round === 0) {
|
|
|
|
promise = Promise.resolve();
|
|
|
|
} else {
|
|
|
|
promise = self.sampleMemoryToStorage();
|
2015-03-20 02:20:43 +03:00
|
|
|
}
|
2015-03-25 22:02:21 +03:00
|
|
|
|
|
|
|
promise.then(function() {
|
2015-03-17 03:26:29 +03:00
|
|
|
if (done) {
|
|
|
|
self.finish();
|
|
|
|
return;
|
|
|
|
}
|
2015-03-25 22:02:21 +03:00
|
|
|
DumbPipe.close(DumbPipe.open("gcReload", {}));
|
|
|
|
}).catch(function (e) {
|
|
|
|
console.error(e)
|
|
|
|
});
|
2015-02-03 20:30:51 +03:00
|
|
|
}
|
2015-02-10 05:53:43 +03:00
|
|
|
if (storage.deleteFs) {
|
|
|
|
console.log("Deleting fs.");
|
|
|
|
indexedDB.deleteDatabase("asyncStorage");
|
|
|
|
}
|
|
|
|
if (storage.deleteJitCache) {
|
|
|
|
console.log("Deleting jit cache.");
|
2015-02-10 06:09:35 +03:00
|
|
|
indexedDB.deleteDatabase("CompiledMethodCache");
|
2015-02-10 05:53:43 +03:00
|
|
|
}
|
2015-03-17 03:26:29 +03:00
|
|
|
if (storage.round !== 0) {
|
|
|
|
console.log("Scheduling round " + (storage.round) + " of " + storage.numRounds + " finalization in " + storage.roundDelay + "ms");
|
|
|
|
setTimeout(run, storage.roundDelay);
|
|
|
|
} else {
|
|
|
|
run();
|
|
|
|
}
|
2015-02-03 20:30:51 +03:00
|
|
|
},
|
2015-02-10 02:54:20 +03:00
|
|
|
finish: function() {
|
2015-02-10 05:53:43 +03:00
|
|
|
storage.running = false;
|
2015-03-13 02:37:57 +03:00
|
|
|
saveStorage();
|
|
|
|
var labels = ["Test", "Baseline Mean", "Mean", "+/-", "%", "P", "Min", "Max"];
|
|
|
|
var rows = [labels];
|
|
|
|
for (var key in storage.current) {
|
|
|
|
var samples = storage.current[key];
|
|
|
|
var baselineSamples = storage.baseline[key] || [];
|
|
|
|
var hasBaseline = baselineSamples.length > 0;
|
|
|
|
var formatter = valueFormatters[key];
|
|
|
|
|
|
|
|
var row = [key];
|
2015-04-28 15:08:31 +03:00
|
|
|
row.untrusted = untrustedValues.indexOf(key) != -1;
|
2015-03-13 02:37:57 +03:00
|
|
|
rows.push(row);
|
|
|
|
var currentMean = mean(samples);
|
|
|
|
var baselineMean = mean(baselineSamples);
|
|
|
|
row.push(hasBaseline ? formatter(baselineMean) + "" : "n/a");
|
|
|
|
row.push(formatter(currentMean) + "");
|
|
|
|
row.push(hasBaseline ? formatter(currentMean - baselineMean) + "" : "n/a");
|
|
|
|
row.push(hasBaseline ? (100 * (currentMean - baselineMean) / baselineMean).toFixed(2) : "n/a");
|
|
|
|
var pMessage = "n/a";
|
|
|
|
if (hasBaseline) {
|
|
|
|
var p = (baselineSamples.length < 2) ? 1 : ttest(baselineSamples, samples).pValue();
|
|
|
|
if (p < 0.05) {
|
|
|
|
pMessage = currentMean < baselineMean ? "BETTER" : "WORSE";
|
|
|
|
} else {
|
2015-04-22 21:03:30 +03:00
|
|
|
pMessage = "SAME";
|
2015-03-13 02:37:57 +03:00
|
|
|
}
|
2015-02-03 20:30:51 +03:00
|
|
|
} else {
|
2015-03-13 02:37:57 +03:00
|
|
|
pMessage = "n/a";
|
2015-02-03 20:30:51 +03:00
|
|
|
}
|
2015-03-13 02:37:57 +03:00
|
|
|
row.push(pMessage);
|
|
|
|
row.push(formatter(Math.min.apply(null, samples)));
|
|
|
|
row.push(formatter(Math.max.apply(null, samples)));
|
2015-02-03 20:30:51 +03:00
|
|
|
}
|
2015-02-10 05:53:43 +03:00
|
|
|
if (storage.buildBaseline) {
|
2015-03-13 02:37:57 +03:00
|
|
|
storage.baseline = storage.current;
|
2015-02-10 05:53:43 +03:00
|
|
|
storage.buildBaseline = false;
|
2015-03-13 02:37:57 +03:00
|
|
|
console.log("FINISHED BUILDING BASELINE");
|
2015-02-10 05:53:43 +03:00
|
|
|
}
|
2015-03-13 02:37:57 +03:00
|
|
|
console.log("Raw Values:\n" + "Current: " + JSON.stringify(storage.current) + "\nBaseline: " + JSON.stringify(storage.baseline))
|
2015-04-08 23:40:22 +03:00
|
|
|
var configRows = [
|
|
|
|
["Config", "Value"],
|
|
|
|
["User Agent", window.navigator.userAgent],
|
|
|
|
["Rounds", storage.numRounds],
|
|
|
|
["Delay(ms)", storage.roundDelay],
|
|
|
|
["Delete FS", storage.deleteFs ? "yes" : "no"],
|
|
|
|
["Delete JIT CACHE", storage.deleteJitCache ? "yes" : "no"],
|
|
|
|
];
|
|
|
|
var out = "\n" +
|
|
|
|
prettyTable(configRows, [LEFT, LEFT]) + "\n" +
|
|
|
|
prettyTable(rows, [LEFT, RIGHT, RIGHT, RIGHT, RIGHT, RIGHT, RIGHT, RIGHT]);
|
|
|
|
console.log(out);
|
2015-03-13 02:37:57 +03:00
|
|
|
saveStorage();
|
2015-02-03 20:30:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// Start right away instead of in init() so we can see any speedups in script loading.
|
2015-02-11 22:23:16 +03:00
|
|
|
if (storage.running) {
|
2015-04-22 23:49:10 +03:00
|
|
|
var now = performance.now();
|
2015-04-22 23:52:06 +03:00
|
|
|
startup.startTimer("startupTime", now);
|
2015-04-22 23:49:10 +03:00
|
|
|
startup.startTimer("vmStartupTime", now);
|
2015-02-11 22:23:16 +03:00
|
|
|
}
|
2015-02-03 20:30:51 +03:00
|
|
|
|
2015-03-09 02:04:31 +03:00
|
|
|
var numRoundsEl;
|
|
|
|
var roundDelayEl;
|
|
|
|
var deleteFsEl;
|
|
|
|
var deleteJitCacheEl;
|
|
|
|
var startButton;
|
|
|
|
var baselineButton;
|
|
|
|
|
|
|
|
function getSettings() {
|
|
|
|
return {
|
|
|
|
numRounds: numRoundsEl.value | 0,
|
|
|
|
roundDelay: roundDelayEl.value | 0,
|
|
|
|
deleteFs: !!deleteFsEl.checked,
|
|
|
|
deleteJitCache: !!deleteJitCacheEl.checked,
|
2015-03-13 02:37:57 +03:00
|
|
|
recordMemory: NO_SECURITY
|
2015-03-09 02:04:31 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function start() {
|
|
|
|
startup.run(getSettings());
|
2015-03-13 02:37:57 +03:00
|
|
|
}
|
2015-03-09 02:04:31 +03:00
|
|
|
|
|
|
|
function buildBaseline() {
|
|
|
|
var settings = getSettings();
|
2015-03-13 02:37:57 +03:00
|
|
|
settings.buildBaseline = true;
|
2015-03-09 02:04:31 +03:00
|
|
|
startup.run(settings);
|
|
|
|
}
|
|
|
|
|
2015-02-03 20:30:51 +03:00
|
|
|
return {
|
2015-02-10 05:53:43 +03:00
|
|
|
initUI: function() {
|
2015-03-09 02:04:31 +03:00
|
|
|
numRoundsEl = document.getElementById("benchmark-num-rounds");
|
|
|
|
roundDelayEl = document.getElementById("benchmark-round-delay");
|
|
|
|
deleteFsEl = document.getElementById("benchmark-delete-fs");
|
|
|
|
deleteJitCacheEl = document.getElementById("benchmark-delete-jit-cache");
|
|
|
|
startButton = document.getElementById("benchmark-startup-run");
|
|
|
|
baselineButton = document.getElementById("benchmark-startup-baseline");
|
2015-02-10 05:53:43 +03:00
|
|
|
|
|
|
|
numRoundsEl.value = storage.numRounds;
|
|
|
|
roundDelayEl.value = storage.roundDelay;
|
|
|
|
deleteFsEl.checked = storage.deleteFs;
|
|
|
|
deleteJitCacheEl.checked = storage.deleteJitCache;
|
|
|
|
|
2015-03-09 02:04:31 +03:00
|
|
|
startButton.onclick = start;
|
|
|
|
baselineButton.onclick = buildBaseline;
|
2015-02-10 05:53:43 +03:00
|
|
|
},
|
2015-03-09 02:04:31 +03:00
|
|
|
start: start,
|
|
|
|
buildBaseline: buildBaseline,
|
2015-03-24 21:25:43 +03:00
|
|
|
sampleMemory: sampleMemory,
|
2015-03-25 22:02:21 +03:00
|
|
|
forceCollectors: forceCollectors,
|
2015-03-24 22:36:44 +03:00
|
|
|
prettyTable: prettyTable,
|
|
|
|
LEFT: LEFT,
|
|
|
|
CENTER: CENTER,
|
|
|
|
RIGHT: RIGHT,
|
2015-02-03 20:30:51 +03:00
|
|
|
startup: {
|
2015-04-21 08:28:04 +03:00
|
|
|
setStartTime: function () {
|
2015-04-22 23:52:06 +03:00
|
|
|
startup.startTime["startupTime"] = startup.startTime["vmStartupTime"] = performance.now();
|
2015-04-21 08:28:04 +03:00
|
|
|
},
|
2015-02-03 20:30:51 +03:00
|
|
|
init: function() {
|
2015-02-11 22:23:16 +03:00
|
|
|
if (!storage.running) {
|
|
|
|
return;
|
|
|
|
}
|
2015-04-22 01:20:48 +03:00
|
|
|
|
|
|
|
var vmImplKey = "com/sun/midp/main/MIDletSuiteUtils.vmEndStartUp.(I)V";
|
|
|
|
var vmOriginalFn = Native[vmImplKey];
|
|
|
|
var vmCalled = false;
|
|
|
|
Native[vmImplKey] = function() {
|
|
|
|
if (!vmCalled) {
|
|
|
|
vmCalled = true;
|
2015-04-22 23:49:10 +03:00
|
|
|
var now = performance.now();
|
|
|
|
startup.stopTimer("vmStartupTime", now);
|
2015-04-22 23:52:06 +03:00
|
|
|
startup.startTimer("bgStartupTime", now);
|
2015-04-22 01:20:48 +03:00
|
|
|
}
|
|
|
|
vmOriginalFn.apply(null, arguments);
|
|
|
|
};
|
|
|
|
|
|
|
|
var bgImplKey = "com/nokia/mid/s40/bg/BGUtils.getFGMIDletClass.()Ljava/lang/String;";
|
|
|
|
var bgOriginalFn = Native[bgImplKey];
|
|
|
|
Native[bgImplKey] = function() {
|
2015-04-22 23:49:10 +03:00
|
|
|
var now = performance.now();
|
2015-04-22 23:52:06 +03:00
|
|
|
startup.stopTimer("bgStartupTime", now);
|
|
|
|
startup.startTimer("fgStartupTime", now);
|
2015-04-22 01:20:48 +03:00
|
|
|
return bgOriginalFn.apply(null, arguments);
|
|
|
|
};
|
|
|
|
|
|
|
|
var fgImplKey = "com/sun/midp/lcdui/DisplayDevice.gainedForeground0.(II)V";
|
|
|
|
var fgOriginalFn = Native[fgImplKey];
|
|
|
|
Native[fgImplKey] = function() {
|
2015-04-22 23:49:10 +03:00
|
|
|
var now = performance.now();
|
2015-04-22 23:52:06 +03:00
|
|
|
startup.stopTimer("fgStartupTime", now);
|
|
|
|
startup.stopTimer("startupTime", now);
|
2015-04-22 01:20:48 +03:00
|
|
|
fgOriginalFn.apply(null, arguments);
|
2015-02-03 20:30:51 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
run: startup.run.bind(startup),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})();
|