gecko/toolkit/components/perf/test_pm.xul
2012-05-21 12:12:37 +01:00

54 lines
1.8 KiB
XML

<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<window title="Performance measurement tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test()">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript"><![CDATA[
function test()
{
SimpleTest.waitForExplicitFinish();
Components.utils.import("resource://gre/modules/PerfMeasurement.jsm");
let pm = new PerfMeasurement(PerfMeasurement.ALL);
if (pm.eventsMeasured == 0) {
todo(false, "stub, skipping test");
} else {
is(pm.eventsMeasured, PerfMeasurement.ALL, "all events measurable");
pm.start();
for (let i = 0; i < 10000; i++) ;
pm.stop();
isnot(pm.cpu_cycles, -1, "cpu_cycles");
isnot(pm.instructions, -1, "instructions");
isnot(pm.cache_references, -1, "cache_references");
isnot(pm.cache_misses, -1, "cache_misses");
isnot(pm.branch_instructions, -1, "branch_instructions");
isnot(pm.branch_misses, -1, "branch_misses");
isnot(pm.bus_cycles, -1, "bus_cycles");
isnot(pm.page_faults, -1, "page_faults");
isnot(pm.major_page_faults, -1, "major_page_faults");
isnot(pm.context_switches, -1, "context_switches");
isnot(pm.cpu_migrations, -1, "cpu_migrations");
}
SimpleTest.finish();
}
]]></script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
<label id="test-result"/>
</window>