| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src="../resources/magnitude-perf.js"></script> |
| <script> |
| var parentForm = null; |
| |
| // FIXME(nbarth): this is O(n^2) |
| // Adding a radio button is O(n), which is what this test is testing, |
| // so building a group 1 button at a time is O(n^2) |
| // Set innerHTML directly instead |
| function setup(magnitude) { |
| if (parentForm) |
| document.body.removeChild(parentForm); |
| parentForm = document.createElement('form'); |
| document.body.appendChild(parentForm); |
| for (var i = 0; i < magnitude; ++i) { |
| var radio = document.createElement('input'); |
| radio.type = 'radio'; |
| radio.name = 'group1'; |
| radio.checked = true; |
| parentForm.appendChild(radio); |
| } |
| parentForm.offsetLeft; |
| } |
| |
| function test(magnitude) { |
| var radio = document.createElement('input'); |
| radio.type = 'radio'; |
| radio.name = 'group1'; |
| radio.checked = true; |
| parentForm.appendChild(radio); |
| radio.offsetLeft; |
| parentForm.removeChild(radio); |
| } |
| |
| Magnitude.description("Tests that adding a radio button to a radio button group is linear in the number of radio buttons."); |
| Magnitude.initialExponent = 12; |
| // dominated by constant and log term for small n |
| Magnitude.numPoints = 3; |
| Magnitude.tolerance = 0.30; |
| Magnitude.run(setup, test, Magnitude.LINEAR); |
| </script> |
| </body> |
| </html> |