1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title>Dojo/on 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="isDebug:true, async:true"></script> |
---|
9 | <script type="text/javascript"> |
---|
10 | require([ |
---|
11 | "dojo/dom", |
---|
12 | "dojo/dom-construct", |
---|
13 | "dojo/on", |
---|
14 | "dojo/query", |
---|
15 | "doh", |
---|
16 | "dojo/domReady!" |
---|
17 | ], function(dom, domConstruct, on, query, doh){ |
---|
18 | |
---|
19 | doh.register("on() performance tests", [ |
---|
20 | { |
---|
21 | name: "1000 on.emit() calls, no listeners", |
---|
22 | testType: "perf", |
---|
23 | trialIterations: 20, |
---|
24 | setUp: function(){ |
---|
25 | dom.byId("status").innerHTML = "Running no listeners test..."; |
---|
26 | button = dom.byId("emitbutton"); |
---|
27 | }, |
---|
28 | tearDown: function(){ |
---|
29 | }, |
---|
30 | runTest: function(){ |
---|
31 | for(var i=0; i<1000; i++){ |
---|
32 | on.emit(button, "myevent", {bubbles: true, cancelable: true}); |
---|
33 | } |
---|
34 | } |
---|
35 | }, |
---|
36 | { |
---|
37 | name: "1000 on.emit() calls, listener on same node", |
---|
38 | testType: "perf", |
---|
39 | trialIterations: 20, |
---|
40 | setUp: function(){ |
---|
41 | dom.byId("status").innerHTML = "Running one listener test..."; |
---|
42 | |
---|
43 | cnt = 0; |
---|
44 | on(button, "myevent", function(evt){ cnt++; } ); |
---|
45 | }, |
---|
46 | tearDown: function(){ |
---|
47 | }, |
---|
48 | runTest: function(){ |
---|
49 | for(var i=0; i<1000; i++){ |
---|
50 | on.emit(button, "myevent", {bubbles: true, cancelable: true}); |
---|
51 | } |
---|
52 | } |
---|
53 | }, |
---|
54 | { |
---|
55 | name: "1000 on.emit() calls, listener on same node and ancestor", |
---|
56 | testType: "perf", |
---|
57 | trialIterations: 20, |
---|
58 | setUp: function(){ |
---|
59 | dom.byId("status").innerHTML = "Running two listener test..."; |
---|
60 | |
---|
61 | on(dom.byId("emit"), "myevent", function(evt){ cnt++; } ); |
---|
62 | }, |
---|
63 | tearDown: function(){ |
---|
64 | }, |
---|
65 | runTest: function(){ |
---|
66 | for(var i=0; i<1000; i++){ |
---|
67 | on.emit(button, "myevent", {bubbles: true, cancelable: true}); |
---|
68 | } |
---|
69 | } |
---|
70 | }, |
---|
71 | |
---|
72 | function results(){ |
---|
73 | dom.byId("status").innerHTML = "Graphing results..."; |
---|
74 | } |
---|
75 | ]); |
---|
76 | |
---|
77 | doh.run(); |
---|
78 | }); |
---|
79 | </script> |
---|
80 | </head> |
---|
81 | <body> |
---|
82 | <h1>Dojo/on Performance Test</h1> |
---|
83 | |
---|
84 | <!-- Display progress messages so test doesn't seem hung --> |
---|
85 | <h2 id="status"></h2> |
---|
86 | |
---|
87 | <!-- Test results are displayed here --> |
---|
88 | <div id="perfTestsBody"></div> |
---|
89 | |
---|
90 | <div id="emit"> |
---|
91 | <div> |
---|
92 | <form id="emitinner"> |
---|
93 | <button id="emitbutton">hi</button> |
---|
94 | </form> |
---|
95 | </div> |
---|
96 | </div> |
---|
97 | </body> |
---|
98 | </html> |
---|