OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <body> | |
4 <script src="../resources/magnitude-perf.js"></script> | |
5 <script> | |
6 var parentForm = null; | |
7 | |
8 // FIXME(nbarth): this is O(n^2) | |
9 // Adding a radio button is O(n), which is what this test is testing, | |
10 // so building a group 1 button at a time is O(n^2) | |
11 // Set innerHTML directly instead | |
12 function setup(magnitude) { | |
13 if (parentForm) | |
14 document.body.removeChild(parentForm); | |
15 parentForm = document.createElement('form'); | |
16 document.body.appendChild(parentForm); | |
17 for (var i = 0; i < magnitude; ++i) { | |
18 var radio = document.createElement('input'); | |
19 radio.type = 'radio'; | |
20 radio.name = 'group1'; | |
21 radio.checked = true; | |
22 parentForm.appendChild(radio); | |
23 } | |
24 parentForm.offsetLeft; | |
25 } | |
26 | |
27 function test(magnitude) { | |
28 var radio = document.createElement('input'); | |
29 radio.type = 'radio'; | |
30 radio.name = 'group1'; | |
31 radio.checked = true; | |
32 parentForm.appendChild(radio); | |
33 radio.offsetLeft; | |
34 parentForm.removeChild(radio); | |
35 } | |
36 | |
37 Magnitude.description("Tests that adding a radio button to a radio button group
is linear in the number of radio buttons."); | |
38 Magnitude.initialExponent = 12; | |
39 // dominated by constant and log term for small n | |
40 Magnitude.numPoints = 3; | |
41 Magnitude.tolerance = 0.30; | |
42 Magnitude.run(setup, test, Magnitude.LINEAR); | |
43 </script> | |
44 </body> | |
45 </html> | |
OLD | NEW |