Home | History | Annotate | Download | only in Events
      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <script type="text/javascript" src="../resources/runner.js"></script>
      5 </head>
      6 <body>
      7 <script>
      8 function appendBranchWithDepth(depth)
      9 {
     10     var node = document.body;
     11     while (depth) {
     12         var child = document.createElement('div');
     13         node.appendChild(child);
     14         node = child;
     15         depth--;
     16     }
     17     return node;
     18 }
     19 
     20 function appendChildren(root, childCount)
     21 {
     22     while (childCount) {
     23         root.appendChild(document.createElement('div'));
     24         childCount--;
     25     }
     26 }
     27 
     28 // This makes a tree of depth 50 with 500 leaves.
     29 var tipOfBranch = appendBranchWithDepth(50);
     30 appendChildren(tipOfBranch, 500);
     31 var customEvent = new Event('foo');
     32 
     33 function run()
     34 {
     35     for (var node = tipOfBranch.firstChild; node; node = node.nextSibling)
     36       node.dispatchEvent(customEvent);
     37 }
     38 
     39 PerfTestRunner.measureRunsPerSecond({
     40     description: "Measure events dispatching",
     41     run: run
     42 });
     43 </script>
     44 </body>
     45 </html>
     46