root / trunk / bench / connect.html

Revision 7030, 2.9 kB (checked in by alex, 23 months ago)

a better test setup for the various conditions and argument permeutations that matter here

  • Property svn:eol-style set to native
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2        "http://www.w3.org/TR/html4/strict.dtd">
3
4<title>dojo.event.connect() test</title>
5
6<style>
7        th { background: #ccccff; }
8        td { align: left; }
9</style>
10
11<script type="text/javascript">
12        djConfig = {
13                debugAtAllCosts: true,
14                isDebug: true
15        };
16</script>
17<script type="text/javascript" src="../dojo.js"></script>
18<script>
19        dojo.require("dojo.event.*");
20        dojo.require("dojo.profile");
21        dojo.require("dojo.debug.console");
22        dojo.hostenv.writeIncludes();
23</script>
24
25<script type="text/javascript">
26
27        function click(){ dojo.debug("i was clicked"); }
28
29        var node;
30        function bench () {
31                var iters = 1000;
32                node = dojo.byId("node");
33
34                function _runBench(str, profile){
35                        var tf = new Function("node", "click", str);
36                        for (var i = 0; i < iters; i++){
37                                if(profile !== false){
38                                        dojo.profile.start(str);
39                                }
40                                tf(node, click);
41                                if(profile !== false){
42                                        dojo.profile.end(str);
43                                }
44                        }
45                }
46
47                _runBench('dojo.event.connect(node, "onclick", "click");');
48                _runBench('dojo.event.disconnect(node, "onclick", "click");', false);
49                _runBench('dojo.event.connect(node, "onclick", click);');
50                _runBench('dojo.event.disconnect(node, "onclick", click);', false);
51                _runBench('dojo.event.connectOnce(node, "onclick", click);');
52                _runBench('dojo.event.disconnect(node, "onclick", click);', false);
53                _runBench('dojo.event.browser.addListener(node, "onclick", click);');
54                _runBench('dojo.event.browser.removeListener(node, "onclick", click);', false);
55                _runBench('dojo.event.kwConnect({srcObj: node, srcFunc: "onclick", adviceFunc: click});');
56                _runBench('dojo.event.kwDisconnect({srcObj: node, srcFunc: "onclick", adviceFunc: click});', false);
57                _runBench('dojo.event.kwConnect({srcObj: node, srcFunc: "onclick", adviceFunc: "click"});');
58                _runBench('dojo.event.kwDisconnect({srcObj: node, srcFunc: "onclick", adviceFunc: "click"});', false);
59       
60                dojo.profile.dump(true);
61        }
62       
63</script>
64
65<h1>Test of dojo.event.connect() (and related functions)</h1>
66
67<p><strong style="color:red">Warning:</strong> these benchmarks will take a number of seconds to run.  Other system activity will cause these benchmarks to skew.
68<p><a href="javascript:bench()">Run benchmarks</a>
69
70<div id="node">
71This is the node which will be connected to
72</div>
73
74<p>The results should not be compared between browsers for they are run on different systems, however results for the same browser are relative to each other.
75
76<div id="profileOutputTable"></div>
77
78<h2>Typical results</h2>
79<table border=1>
80<thead>
81        <tr>
82                <td>
83                <th>IE
84                <th>Safari
85                <th>Gecko (on PC)
86                <th>Gecko (on intel mac)
87        </tr>
88</thead>
89<tbody>
90        <tr>
91                <th>dojo.event.connect()
92                <td>hang!
93                <td>842
94                <td>437
95                <td>523
96        </tr>
97        <tr>
98                <th>dojo.event.connectOnce()
99                <td>?
100                <td>856
101                <td>344
102                <td>521
103        </tr>
104        <tr>
105                <th>dojo.event.browser.addListener()
106                <td>?
107                <td>97
108                <td>125
109                <td>100
110        </tr>
111        <tr>
112                <th>dojo.event.kwConnect()
113                <td>?
114                <td>744
115                <td>344
116                <td>658
117        </tr>
118</tbody>
119</table>
Note: See TracBrowser for help on using the browser.