toolkit/components/perf/test_pm.xul

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 <?xml version="1.0"?>
     2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     3    - License, v. 2.0. If a copy of the MPL was not distributed with this
     4    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     6 <window title="Performance measurement tests"
     7         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     8         onload="test()">
    10   <script type="application/javascript"
    11           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    12   <script type="application/javascript"
    13           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    15   <script type="application/javascript"><![CDATA[
    16 function test()
    17 {
    18   SimpleTest.waitForExplicitFinish();
    20   Components.utils.import("resource://gre/modules/PerfMeasurement.jsm");
    21   let pm = new PerfMeasurement(PerfMeasurement.ALL);
    22   if (pm.eventsMeasured == 0) {
    23     todo(false, "stub, skipping test");
    24   } else {
    25     pm.start();
    26     for (let i = 0; i < 10000; i++) ;
    27       pm.stop();
    29     events = ["cpu_cycles", "instructions", "cache_references", "cache_misses",
    30               "branch_instructions", "branch_misses", "bus_cycles", "page_faults",
    31               "major_page_faults", "context_switches", "cpu_migrations"];
    33     for (var i = 0; i < events.length; i++) {
    34         var e = events[i];
    35         ((pm.eventsMeasured & PerfMeasurement[e.toUpperCase()]) ? isnot : todo_is)(pm[e], -1, e);
    36     }
    37   }
    38   SimpleTest.finish();
    39 }
    40 ]]></script>
    42   <body xmlns="http://www.w3.org/1999/xhtml">
    43     <p id="display"></p>
    44     <div id="content" style="display:none;"></div>
    45     <pre id="test"></pre>
    46   </body>
    47   <label id="test-result"/>
    48 </window>

mercurial