widget_construction_test.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>test of various synchronous page searching methods</title>
  6. <style type="text/css">
  7. @import "../../dojo/resources/dojo.css";
  8. @import "../themes/tundra/tundra.css";
  9. </style>
  10. <script type="text/javascript" src="../../dojo/dojo.js"
  11. djConfig="parseOnLoad: true, isDebug: true"></script>
  12. <script type="text/javascript">
  13. dojo.require("dojo.parser"); // scan page for widgets and instantiate them
  14. dojo.require("dijit._Widget");
  15. dojo.require("dijit._Templated");
  16. /* dummy widget for benchmarking purposes */
  17. dojo.declare(
  18. "SimpleButton",
  19. [ dijit._Widget, dijit._Templated ],
  20. function(){ },
  21. {
  22. label: "",
  23. templateString: "<button dojoAttachEvent='onclick:onClick'>${label}</button>",
  24. onClick: function(){
  25. this.domNode.style.backgroundColor="green";
  26. },
  27. postCreate: function(){
  28. }
  29. }
  30. );
  31. </script>
  32. </head>
  33. <body>
  34. <h1 style="font-size: 40px; line-height: 50px;">This page contains a huge number of nodes, most of which are "chaff".</h1>
  35. <h3>Here's the relative timings for this page</h3>
  36. <div id="profileOutputTable"></div>
  37. <!--
  38. <h3>And some comparison data</h3>
  39. <table border=1>
  40. <thead>
  41. <tr>
  42. <th>IE
  43. <th>Safari
  44. <th>Gecko (on PC)
  45. <th>Gecko (on intel mac)
  46. </tr>
  47. </thead>
  48. <tbody>
  49. <tr>
  50. <td>4890
  51. <td>3242
  52. <td>3094
  53. <td>3782
  54. </tr>
  55. </tbody>
  56. </table>
  57. -->
  58. <?
  59. $containerDepth = 30;
  60. $leadingChaff = 100;
  61. $trailingChaff = 100;
  62. $items = 100;
  63. ?>
  64. <?
  65. function generateChaff($iters){
  66. for($i=0;$i<$iters;$i++){ ?>
  67. <pre class="highlighted"><code><span class="hl-reserved">var </span><span class="hl-identifier">dlg</span><span class="hl-default"> = </span><span class="hl-reserved">new </span><span class="hl-identifier">blah</span><span class="hl-default">.</span><span class="hl-identifier">ext</span><span class="hl-default">.</span><span class="hl-identifier">LayoutDialog</span><span class="hl-brackets">(</span><span class="hl-identifier">config</span><span class="hl-code">.</span><span class="hl-identifier">id</span><span class="hl-code"> || </span><span class="hl-identifier">blah</span><span class="hl-code">.</span><span class="hl-identifier">util</span><span class="hl-code">.</span><span class="hl-identifier">Dom</span><span class="hl-code">.</span><span class="hl-identifier">generateId</span><span class="hl-brackets">()</span><span class="hl-code">, </span><span class="hl-brackets">{
  68. </span><span title="autoCreate" class="hl-identifier">autoCreate</span><span class="hl-code"> : </span><span class="hl-reserved">true</span><span class="hl-code">,
  69. </span><span title="minWidth" class="hl-identifier">minWidth</span><span class="hl-code">:</span><span class="hl-number">400</span><span class="hl-code">,
  70. </span><span title="minHeight" class="hl-identifier">minHeight</span><span class="hl-code">:</span><span class="hl-number">300</span><span class="hl-code">,
  71. </span>
  72. <span title="syncHeightBeforeShow" class="hl-identifier">syncHeightBeforeShow</span><span class="hl-code">: </span><span class="hl-reserved">true</span><span class="hl-code">,
  73. </span><span title="shadow" class="hl-identifier">shadow</span><span class="hl-code">:</span><span class="hl-reserved">true</span><span class="hl-code">,
  74. </span><span title="fixedcenter" class="hl-identifier">fixedcenter</span><span class="hl-code">: </span><span class="hl-reserved">true</span><span class="hl-code">,
  75. </span><span title="center" class="hl-identifier">center</span><span class="hl-code">:</span><span class="hl-brackets">{</span><span class="hl-identifier">autoScroll</span><span class="hl-code">:</span><span class="hl-reserved">false</span><span class="hl-brackets">}</span><span class="hl-code">,
  76. </span><span title="east" class="hl-identifier">east</span><span class="hl-code">:</span><span class="hl-brackets">{</span><span class="hl-identifier">split</span><span class="hl-code">:</span><span class="hl-reserved">true</span><span class="hl-code">,</span><span class="hl-identifier">initialSize</span><span class="hl-code">:</span><span class="hl-number">150</span><span class="hl-code">,</span><span class="hl-identifier">minSize</span><span class="hl-code">:</span><span class="hl-number">150</span><span class="hl-code">,</span><span class="hl-identifier">maxSize</span><span class="hl-code">:</span><span class="hl-number">250</span><span class="hl-brackets">}
  77. })</span><span class="hl-default">;
  78. </span><span class="hl-identifier">dlg</span><span class="hl-default">.</span><span class="hl-identifier">setTitle</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Choose an Image</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-default">;
  79. </span><span class="hl-identifier">dlg</span><span class="hl-default">.</span><span class="hl-identifier">getEl</span><span class="hl-brackets">()</span><span class="hl-default">.</span><span class="hl-identifier">addClass</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">ychooser-dlg</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-default">;</span></code></pre><br />
  80. <pre class="highlighted"><code><span class="hl-reserved">var </span><span class="hl-identifier">animated</span><span class="hl-default"> = </span><span class="hl-reserved">new </span><span class="hl-identifier">blah</span><span class="hl-default">.</span><span class="hl-identifier">ext</span><span class="hl-default">.</span><span class="hl-identifier">Resizable</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">animated</span><span class="hl-quotes">'</span><span class="hl-code">, </span><span class="hl-brackets">{
  81. </span><span title="east" class="hl-identifier">width</span><span class="hl-code">: </span><span class="hl-number">200</span><span class="hl-code">,
  82. </span><span title="east" class="hl-identifier">height</span><span class="hl-code">: </span><span class="hl-number">100</span><span class="hl-code">,
  83. </span><span title="east" class="hl-identifier">minWidth</span><span class="hl-code">:</span><span class="hl-number">100</span><span class="hl-code">,
  84. </span><span class="hl-identifier">minHeight</span><span class="hl-code">:</span><span class="hl-number">50</span><span class="hl-code">,
  85. </span><span class="hl-identifier">animate</span><span class="hl-code">:</span><span class="hl-reserved">true</span><span class="hl-code">,
  86. </span><span class="hl-identifier">easing</span><span class="hl-code">: </span><span class="hl-identifier">YAHOO</span><span class="hl-code">.</span><span class="hl-identifier">util</span><span class="hl-code">.</span><span class="hl-identifier">Easing</span><span class="hl-code">.</span><span class="hl-identifier">backIn</span><span class="hl-code">,
  87. </span><span class="hl-identifier">duration</span><span class="hl-code">:</span><span class="hl-number">.6
  88. </span><span class="hl-brackets">})</span><span class="hl-default">;</span></code></pre>
  89. <h4>The standard Lorem Ipsum passage, used since the 1500s</h4>
  90. <p>
  91. "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
  92. eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
  93. ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
  94. aliquip ex ea commodo consequat. Duis aute irure dolor in
  95. reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
  96. pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
  97. culpa qui officia deserunt mollit anim id est laborum."
  98. </p>
  99. <h4>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h4>
  100. <p>
  101. "Sed ut perspiciatis unde omnis iste natus error sit voluptatem
  102. accusantium doloremque laudantium, totam rem aperiam, eaque ipsa
  103. quae ab illo inventore veritatis et quasi architecto beatae vitae
  104. dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit
  105. aspernatur aut odit aut fugit, sed quia consequuntur magni dolores
  106. eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam
  107. est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
  108. velit, sed quia non numquam eius modi tempora incidunt ut labore et
  109. dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam,
  110. quis nostrum exercitationem ullam corporis suscipit laboriosam,
  111. nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
  112. reprehenderit qui in ea voluptate velit esse quam nihil molestiae
  113. consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla
  114. pariatur?"
  115. </p>
  116. <h4>1914 translation by H. Rackham</h4>
  117. <p>
  118. "But I must explain to you how all this mistaken idea of denouncing
  119. pleasure and praising pain was born and I will give you a complete
  120. account of the system, and expound the actual teachings of the
  121. great explorer of the truth, the master-builder of human happiness.
  122. No one rejects, dislikes, or avoids pleasure itself, because it is
  123. pleasure, but because those who do not know how to pursue pleasure
  124. rationally encounter consequences that are extremely painful. Nor
  125. again is there anyone who loves or pursues or desires to obtain
  126. pain of itself, because it is pain, but because occasionally
  127. circumstances occur in which toil and pain can procure him some
  128. great pleasure. To take a trivial example, which of us ever
  129. undertakes laborious physical exercise, except to obtain some
  130. advantage from it? But who has any right to find fault with a man
  131. who chooses to enjoy a pleasure that has no annoying consequences,
  132. or one who avoids a pain that produces no resultant pleasure?"
  133. </p>
  134. <? }
  135. } // end generateChaff
  136. $widgetName = "SimpleButton";
  137. ?>
  138. <? generateChaff($leadingChaff); ?>
  139. <hr>
  140. <? for($i=0;$i<$containerDepth;$i++){ ?>
  141. <table border="1" cellpadding="0" cellspacing="0" width="100%">
  142. <!--
  143. <table>
  144. -->
  145. <tr>
  146. <td>
  147. <br>
  148. chaff!
  149. <br>
  150. <? } ?>
  151. <? for($i=0;$i<$items;$i++){ ?>
  152. <div dojoType="<?= $widgetName ?>" label="item2 <?= $i ?>">item2 <?= $i ?></div>
  153. <? } ?>
  154. <? for($i=0;$i<$containerDepth;$i++){ ?>
  155. </td>
  156. </tr>
  157. </table>
  158. <? } ?>
  159. <? generateChaff($trailingChaff); ?>
  160. <? for($i=0;$i<$items;$i++){ ?>
  161. <div dojoType="<?= $widgetName ?>" label="item2 <?= $i ?>"><span>item <?= $i ?></span></div>
  162. <? } ?>
  163. <script type="text/javascript">
  164. oldTime = new Date();
  165. dojo.addOnLoad(function(){
  166. var time = new Date().getTime() - oldTime;
  167. var p = document.createElement("p");
  168. alert("Widgets loaded in " + time + "ms");
  169. });
  170. </script>
  171. </body>
  172. </html>