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