[483] | 1 | <!DOCTYPE html> |
---|
| 2 | <html> |
---|
| 3 | <head> |
---|
| 4 | <title>Parser scan() Performance Test</title> |
---|
| 5 | <style type="text/css"> |
---|
| 6 | @import "../../resources/dojo.css"; |
---|
| 7 | </style> |
---|
| 8 | <script type="text/javascript" src="../../dojo.js" data-dojo-config="async:true"></script> |
---|
| 9 | <script type="text/javascript"> |
---|
| 10 | require([ |
---|
| 11 | "dojo/_base/declare", |
---|
| 12 | "dojo/dom", |
---|
| 13 | "dojo/dom-construct", |
---|
| 14 | "dojo/_base/lang", |
---|
| 15 | "dojo/parser", |
---|
| 16 | "dojo/query", |
---|
| 17 | "doh", |
---|
| 18 | "dojo/domReady!" |
---|
| 19 | ], function(declare, dom, domConstruct, lang, parser, query, doh){ |
---|
| 20 | |
---|
| 21 | declare("TabContainer", null, { |
---|
| 22 | numberProp1: 1, |
---|
| 23 | numberProp2: 2, |
---|
| 24 | booleanProp1: false, |
---|
| 25 | booleanProp2: true, |
---|
| 26 | strProp1: "original1", |
---|
| 27 | strProp2: "original2", |
---|
| 28 | funcProp: function(){} |
---|
| 29 | }); |
---|
| 30 | declare("ContentPane", null, { |
---|
| 31 | stopParser: true, |
---|
| 32 | numberProp1: 1, |
---|
| 33 | numberProp2: 2, |
---|
| 34 | booleanProp1: false, |
---|
| 35 | booleanProp2: true, |
---|
| 36 | strProp1: "original1", |
---|
| 37 | strProp2: "original2", |
---|
| 38 | funcProp: function(){} |
---|
| 39 | }); |
---|
| 40 | declare("TextBox", null, { |
---|
| 41 | numberProp1: 1, |
---|
| 42 | numberProp2: 2, |
---|
| 43 | booleanProp1: false, |
---|
| 44 | booleanProp2: true, |
---|
| 45 | strProp1: "original1", |
---|
| 46 | strProp2: "original2", |
---|
| 47 | funcProp: function(){} |
---|
| 48 | }); |
---|
| 49 | |
---|
| 50 | function generateDom(/*String[]*/ nodes, /*Number*/ fan, /*DOMNode*/ parent){ |
---|
| 51 | // summary: |
---|
| 52 | // Generate large DOM tree based on nodes in nodes[] array, with fan nodes at each level |
---|
| 53 | var markup = nodes.shift(); |
---|
| 54 | for(var i=0; i<fan; i++){ |
---|
| 55 | var child = domConstruct.place(markup, parent); |
---|
| 56 | if(nodes.length){ |
---|
| 57 | generateDom([].concat(nodes), fan, child); // concat() to clone array |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | doh.register("parser performance tests", [ |
---|
| 63 | // Test scan of DOM without any widgets |
---|
| 64 | { |
---|
| 65 | name: "scan() with no widgets", |
---|
| 66 | testType: "perf", |
---|
| 67 | trialIterations: 20, |
---|
| 68 | setUp: function(){ |
---|
| 69 | dom.byId("status").innerHTML = "Running scan() with no widgets test..."; |
---|
| 70 | var rows = query("tr", "tbody"); |
---|
| 71 | for(var i=0; i<55; i++){ |
---|
| 72 | domConstruct.place(rows[i%2 + 1].cloneNode(true), "tbody"); |
---|
| 73 | } |
---|
| 74 | }, |
---|
| 75 | tearDown: function(){ |
---|
| 76 | domConstruct.empty("scan"); |
---|
| 77 | }, |
---|
| 78 | runTest: function(){ |
---|
| 79 | parser._clearCache(); |
---|
| 80 | parser.parse("scan"); |
---|
| 81 | } |
---|
| 82 | }, |
---|
| 83 | |
---|
| 84 | { |
---|
| 85 | name: "scan() with lots of widgets", |
---|
| 86 | testType: "perf", |
---|
| 87 | trialIterations: 20, |
---|
| 88 | setUp: function(){ |
---|
| 89 | dom.byId("status").innerHTML = "Running scan() with lots of widgets test..."; |
---|
| 90 | generateDom([ |
---|
| 91 | "<div data-dojo-type=TabContainer></div>", |
---|
| 92 | "<div data-dojo-type=TabContainer></div>", |
---|
| 93 | "<div></div>", |
---|
| 94 | "<input data-dojo-type=TextBox strProp1=name/>" |
---|
| 95 | ], 4, "scan"); |
---|
| 96 | }, |
---|
| 97 | tearDown: function(){ |
---|
| 98 | domConstruct.empty("scan"); |
---|
| 99 | }, |
---|
| 100 | runTest: function(){ |
---|
| 101 | parser._clearCache(); |
---|
| 102 | parser.parse("scan"); |
---|
| 103 | } |
---|
| 104 | }, |
---|
| 105 | |
---|
| 106 | { |
---|
| 107 | name: "scan() with lots of widgets but _stopParser", |
---|
| 108 | testType: "perf", |
---|
| 109 | trialIterations: 20, |
---|
| 110 | setUp: function(){ |
---|
| 111 | dom.byId("status").innerHTML = "Running scan() with lots of widgets and _stopParser test..."; |
---|
| 112 | generateDom([ |
---|
| 113 | "<div data-dojo-type=TabContainer></div>", |
---|
| 114 | "<div data-dojo-type=ContentPane></div>", |
---|
| 115 | "<div></div>", |
---|
| 116 | "<input data-dojo-type=TextBox strProp1=name/>" |
---|
| 117 | ], 4, "scan"); |
---|
| 118 | }, |
---|
| 119 | tearDown: function(){ |
---|
| 120 | domConstruct.empty("scan"); |
---|
| 121 | }, |
---|
| 122 | runTest: function(){ |
---|
| 123 | parser._clearCache(); |
---|
| 124 | parser.parse("scan"); |
---|
| 125 | } |
---|
| 126 | }, |
---|
| 127 | |
---|
| 128 | { |
---|
| 129 | name: "instantiate()", |
---|
| 130 | testType: "perf", |
---|
| 131 | trialIterations: 20, |
---|
| 132 | setUp: function(){ |
---|
| 133 | dom.byId("status").innerHTML = "Running instantiate() test..."; |
---|
| 134 | nodes = []; |
---|
| 135 | for(var i=0; i<100; i++){ |
---|
| 136 | nodes.push(domConstruct.place("<input data-dojo-type=TextBox numberProp1=1 numberProp2=2 stringProp1=hi booleanProp1=true funcProp='console.log(12345);'/>", "instantiate")); |
---|
| 137 | } |
---|
| 138 | }, |
---|
| 139 | tearDown: function(){ |
---|
| 140 | domConstruct.empty("instantiate"); |
---|
| 141 | }, |
---|
| 142 | runTest: function(){ |
---|
| 143 | parser._clearCache(); |
---|
| 144 | parser.instantiate(nodes); |
---|
| 145 | } |
---|
| 146 | }, |
---|
| 147 | |
---|
| 148 | function results(){ |
---|
| 149 | dom.byId("status").innerHTML = "Graphing results..."; |
---|
| 150 | } |
---|
| 151 | ]); |
---|
| 152 | |
---|
| 153 | doh.run(); |
---|
| 154 | }); |
---|
| 155 | </script> |
---|
| 156 | </head> |
---|
| 157 | <body> |
---|
| 158 | <h1>Parser Performance Test</h1> |
---|
| 159 | |
---|
| 160 | <!-- Display progress messages so test doesn't seem hung --> |
---|
| 161 | <h2 id="status"></h2> |
---|
| 162 | |
---|
| 163 | <!-- Test results are displayed here --> |
---|
| 164 | <div id="perfTestsBody"></div> |
---|
| 165 | |
---|
| 166 | <!-- for generating markup to scan (no widgets, just nodes) --> |
---|
| 167 | <div id="scan" style="display: none"> |
---|
| 168 | <table width="100%" cellspacing="0" cellpadding="0" border="0" class="datatable" id="reportTable"> |
---|
| 169 | <tbody id="tbody"> |
---|
| 170 | <tr class="hr"> |
---|
| 171 | <td width="1px" style="display: none;"> |
---|
| 172 | <input type="checkbox" onclick="" name="cbSelectItem" ignore="true"> |
---|
| 173 | </td> |
---|
| 174 | <td class="left"> |
---|
| 175 | <span id="_0"> |
---|
| 176 | Name |
---|
| 177 | </span> |
---|
| 178 | </td> |
---|
| 179 | |
---|
| 180 | <td class="left"> |
---|
| 181 | <span id="_1"> |
---|
| 182 | RIC |
---|
| 183 | </span> |
---|
| 184 | </td> |
---|
| 185 | |
---|
| 186 | <td class="right"> |
---|
| 187 | <span id="_2"> |
---|
| 188 | PE |
---|
| 189 | </span> |
---|
| 190 | </td> |
---|
| 191 | |
---|
| 192 | <td class="right"> |
---|
| 193 | Est. PE |
---|
| 194 | </td> |
---|
| 195 | |
---|
| 196 | <td class="right"> |
---|
| 197 | <span id="_4"> |
---|
| 198 | EPS |
---|
| 199 | </span> |
---|
| 200 | </td> |
---|
| 201 | |
---|
| 202 | <td class="normaltext left"> |
---|
| 203 | Ccy |
---|
| 204 | </td> |
---|
| 205 | |
---|
| 206 | <td class="right"> |
---|
| 207 | <span id="_6"> |
---|
| 208 | DPS |
---|
| 209 | </span> |
---|
| 210 | </td> |
---|
| 211 | |
---|
| 212 | <td class="normaltext left"> |
---|
| 213 | Ccy |
---|
| 214 | </td> |
---|
| 215 | |
---|
| 216 | <td class="right"> |
---|
| 217 | <span id="_8"> |
---|
| 218 | Div. Yld (%) |
---|
| 219 | </span> |
---|
| 220 | </td> |
---|
| 221 | |
---|
| 222 | <td class="right"> |
---|
| 223 | <span id="_9"> |
---|
| 224 | ROE (%) |
---|
| 225 | </span> |
---|
| 226 | </td> |
---|
| 227 | |
---|
| 228 | <td class="right"> |
---|
| 229 | <span id="_10"> |
---|
| 230 | P/Book |
---|
| 231 | </span> |
---|
| 232 | </td> |
---|
| 233 | |
---|
| 234 | <td class="right"> |
---|
| 235 | <span id="_11"> |
---|
| 236 | P/Sales |
---|
| 237 | </span> |
---|
| 238 | </td> |
---|
| 239 | |
---|
| 240 | <td class="normaltext right"> |
---|
| 241 | Weight % |
---|
| 242 | </td> |
---|
| 243 | |
---|
| 244 | <td class="right"> |
---|
| 245 | <span id="_12"> |
---|
| 246 | Market Cap (USD) |
---|
| 247 | </span> |
---|
| 248 | </td> |
---|
| 249 | |
---|
| 250 | </tr> |
---|
| 251 | |
---|
| 252 | |
---|
| 253 | <tr headrow="true" class="dr row-o"> |
---|
| 254 | <td width="1px" style="display: none;"> |
---|
| 255 | <input type="checkbox" value="IBM.N" name="cbSelectItem" ignore=""> |
---|
| 256 | </td> |
---|
| 257 | <td class="normaltext left"> |
---|
| 258 | International Business Machines Corp |
---|
| 259 | </td> |
---|
| 260 | <td class="normaltext left"><span style=""> |
---|
| 261 | <a href="#" class="CCFDATA CCF.Entity[COMP]:RIC=RIC"> |
---|
| 262 | RIC |
---|
| 263 | </a> |
---|
| 264 | </span><span style="visibility: hidden; display: none;">-</span></td> |
---|
| 265 | <td class="normaltext right">xx,xx</td> |
---|
| 266 | <td class="normaltext right">xx,xx</td> |
---|
| 267 | <td class="normaltext right">x,xx</td> |
---|
| 268 | <td class="normaltext left nowrap">XXX</td> |
---|
| 269 | <td class="normaltext right">xx.xx,xx</td> |
---|
| 270 | <td class="normaltext left nowrap">XXX</td> |
---|
| 271 | <td class="normaltext right">x,xx</td> |
---|
| 272 | <td class="normaltext right">xx,xx</td> |
---|
| 273 | <td class="normaltext right">x,xx</td> |
---|
| 274 | <td class="normaltext right">x,xx</td> |
---|
| 275 | <td class="normaltext right">-</td> |
---|
| 276 | <td class="normaltext right">xxx,xxx</td> |
---|
| 277 | </tr> |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | <tr headrow="true" class="dr row-e"> |
---|
| 281 | <td width="1px" style="display: none;"> |
---|
| 282 | <input type="checkbox" value=" " name="cbSelectItem" ignore="true"> |
---|
| 283 | </td> |
---|
| 284 | <td class="normaltext left"> |
---|
| 285 | Index average (Mean)</td> |
---|
| 286 | <td class="normaltext left"><span style="visibility: hidden; display: none;"> |
---|
| 287 | <a href="/Explorer/Default.aspx?s=%26nbsp&amp;st=RIC" class="CCFDATA CCF.Entity[COMP]:RIC=&nbsp"> |
---|
| 288 | |
---|
| 289 | </a> |
---|
| 290 | </span><span style="">-</span></td> |
---|
| 291 | <td class="normaltext right">xx,xx</td> |
---|
| 292 | <td class="normaltext right">xx,xx</td> |
---|
| 293 | <td class="normaltext right">n/a</td> |
---|
| 294 | <td class="normaltext left nowrap">n/a</td> |
---|
| 295 | <td class="normaltext right">n/a</td> |
---|
| 296 | <td class="normaltext left nowrap">n/a</td> |
---|
| 297 | <td class="normaltext right">xx,xx</td> |
---|
| 298 | <td class="normaltext right">xx,xx</td> |
---|
| 299 | <td class="normaltext right">x,xx</td> |
---|
| 300 | <td class="normaltext right">x,xx</td> |
---|
| 301 | <td class="normaltext right">-</td> |
---|
| 302 | <td class="normaltext right">xx,xxx</td> |
---|
| 303 | </tr> |
---|
| 304 | </tbody> |
---|
| 305 | </table> |
---|
| 306 | </div> |
---|
| 307 | |
---|
| 308 | <!-- for testing widget instantiation speed --> |
---|
| 309 | <div id="instantiate" style="display: none"></div> |
---|
| 310 | </body> |
---|
| 311 | </html> |
---|