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