Make sure that unbinding on a plain javascript object works correctly. Fixes #6184.
[jquery.git] / speed / event.html
1 <!doctype html>
2 <html>
3 <head>
4         <title>Test Event Handling Performance</title>
5         <script src="benchmark.js"></script>
6         <script src="jquery-basis.js"></script>
7         <script>var old = jQuery.noConflict(true);</script>
8         <script src="../dist/jquery.js"></script>
9         <script>
10         jQuery(function(){
11         
12         });
13
14         var events = [], num = 400, exec = false;
15
16         jQuery(document).mousemove(function(e){
17                 if ( exec ) {
18                         return;
19                 }
20
21                 if ( events.length >= num ) {
22                         exec = true;
23                         var s = (new Date).getTime();
24
25                         for ( var n = 0; n < 5; n++ ) {
26                                 for ( var i = 0; i < num; i++ ) {
27                                         old.event.handle.call( document, events[i] );
28                                 }
29                         }
30
31                         var oldNum = (new Date).getTime() - s;
32
33                         s = (new Date).getTime();
34
35                         for ( var n = 0; n < 5; n++ ) {
36                                 for ( var i = 0; i < num; i++ ) {
37                                         jQuery.event.handle.call( document, events[i] );
38                                 }
39                         }
40
41                         var curNum = (new Date).getTime() - s;
42
43                         jQuery("#num").text( old.fn.jquery + ": " + oldNum + " " + jQuery.fn.jquery + ": " + curNum );
44
45                         jQuery(this).unbind( "mousemove", e.handler );
46
47                 } else {
48                         events.push( e.originalEvent );
49                         jQuery("#num").text( events.length + " / " + num );
50                 }
51         });
52         </script>
53 </head>
54 <body>
55         <p>Move the mouse, please!</p>
56         <p id="num"></p>
57 </body>
58 </html>