container_perf.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2009 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <!--
  9. -->
  10. <head>
  11. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  12. <title>Closure Performance Tests - goog.ui.Container</title>
  13. <link rel="stylesheet" type="text/css" href="../testing/performancetable.css"/>
  14. <script src="../base.js"></script>
  15. <script>
  16. goog.require('goog.testing.PerformanceTable');
  17. goog.require('goog.testing.jsunit');
  18. goog.require('goog.ui.Container');
  19. goog.require('goog.ui.Control');
  20. </script>
  21. </head>
  22. <body>
  23. <h1>goog.ui.Container Performance Tests</h1>
  24. <p>
  25. <strong>User-agent:</strong>
  26. <script>document.write(navigator.userAgent);</script>
  27. </p>
  28. <div id="perfTable"></div>
  29. <hr>
  30. <script>
  31. var table = new goog.testing.PerformanceTable(
  32. goog.dom.getElement('perfTable'));
  33. // Number of controls to add to the container per test run.
  34. var SAMPLES_PER_RUN = 500;
  35. function testContainerAddChild() {
  36. var description = 'Add ' + SAMPLES_PER_RUN +
  37. ' child controls to the container with immediate rendering';
  38. table.run(function() {
  39. var container = new goog.ui.Container();
  40. for (var i = 0; i < SAMPLES_PER_RUN; i++) {
  41. container.addChild(new goog.ui.Control(), true);
  42. }
  43. container.render();
  44. assertEquals('container child count', SAMPLES_PER_RUN,
  45. container.getChildCount());
  46. container.dispose();
  47. }, description);
  48. }
  49. </script>
  50. </body>
  51. </html>