OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/runner.js"></script> |
| 3 <!-- This is a micro benchmark to catch an unintentional regression. |
| 4 If the reason of a regression is clear, it is okay. |
| 5 We do not have to optimize the result of the benchmark. --> |
| 6 <div id="wrapper"> |
| 7 <div id="host"></div> |
| 8 </div> |
| 9 <script> |
| 10 'use strict'; |
| 11 const numChildOfHost = 20; |
| 12 const numDivsInShadow = 20; |
| 13 const loops = 100; |
| 14 |
| 15 const slot1 = document.createElement('slot'); |
| 16 slot1.setAttribute('name', 'slot1'); |
| 17 const slot2 = document.createElement('slot'); |
| 18 slot2.setAttribute('name', 'slot2'); |
| 19 const shadowRoot = host.attachShadow({mode: 'open'}); |
| 20 shadowRoot.appendChild(slot1); |
| 21 shadowRoot.appendChild(slot2); |
| 22 |
| 23 for (let i = 0; i < numDivsInShadow; ++i) { |
| 24 let div = document.createElement('div'); |
| 25 shadowRoot.appendChild(div); |
| 26 } |
| 27 |
| 28 for (let i = 0; i < numChildOfHost; ++i) { |
| 29 let div1 = document.createElement('div'); |
| 30 div1.setAttribute('slot', 'slot1'); |
| 31 host.appendChild(div1); |
| 32 let div2 = document.createElement('div'); |
| 33 div2.setAttribute('slot', 'slot2'); |
| 34 host.appendChild(div2); |
| 35 } |
| 36 |
| 37 function run() { |
| 38 for (let i = 0; i < loops; ++i) { |
| 39 const slot3 = document.createElement('slot'); |
| 40 slot1.setAttribute('name', 'slot3'); |
| 41 const slot4 = document.createElement('slot'); |
| 42 slot1.setAttribute('name', 'slot1'); |
| 43 slot3.remove(); |
| 44 slot4.remove(); |
| 45 } |
| 46 } |
| 47 |
| 48 PerfTestRunner.measureRunsPerSecond({ |
| 49 description: "Measure v1 distribution performance", |
| 50 run: run, |
| 51 done: () => { |
| 52 wrapper.innerHTML = ''; |
| 53 } |
| 54 }); |
| 55 </script> |
OLD | NEW |