aboutsummaryrefslogtreecommitdiffstats
path: root/speed
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-02-04 22:43:23 -0500
committerjeresig <jeresig@gmail.com>2010-02-04 22:43:23 -0500
commit6f7adb95c1f87869e071541c7e5c92a6189db713 (patch)
tree1c35c4a6b196a818773a5787fb4508c23ec7ac88 /speed
parent9118828a590b844a93c5465ccbee129c30f5a569 (diff)
downloadjquery-6f7adb95c1f87869e071541c7e5c92a6189db713.tar.gz
jquery-6f7adb95c1f87869e071541c7e5c92a6189db713.zip
Add in a test for testing the performance of event handling.
Diffstat (limited to 'speed')
-rw-r--r--speed/event.html58
1 files changed, 58 insertions, 0 deletions
diff --git a/speed/event.html b/speed/event.html
new file mode 100644
index 000000000..6d463b4d8
--- /dev/null
+++ b/speed/event.html
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+ <title>Test Event Handling Performance</title>
+ <script src="benchmark.js"></script>
+ <script src="jquery-basis.js"></script>
+ <script>var old = jQuery.noConflict(true);</script>
+ <script src="../dist/jquery.js"></script>
+ <script>
+ jQuery(function(){
+
+ });
+
+ var events = [], num = 400, exec = false;
+
+ jQuery(document).mousemove(function(e){
+ if ( exec ) {
+ return;
+ }
+
+ if ( events.length >= num ) {
+ exec = true;
+ var s = (new Date).getTime();
+
+ for ( var n = 0; n < 5; n++ ) {
+ for ( var i = 0; i < num; i++ ) {
+ old.event.handle.call( document, events[i] );
+ }
+ }
+
+ var oldNum = (new Date).getTime() - s;
+
+ s = (new Date).getTime();
+
+ for ( var n = 0; n < 5; n++ ) {
+ for ( var i = 0; i < num; i++ ) {
+ jQuery.event.handle.call( document, events[i] );
+ }
+ }
+
+ var curNum = (new Date).getTime() - s;
+
+ jQuery("#num").text( old.fn.jquery + ": " + oldNum + " " + jQuery.fn.jquery + ": " + curNum );
+
+ jQuery(this).unbind( "mousemove", e.handler );
+
+ } else {
+ events.push( e.originalEvent );
+ jQuery("#num").text( events.length + " / " + num );
+ }
+ });
+ </script>
+</head>
+<body>
+ <p>Move the mouse, please!</p>
+ <p id="num"></p>
+</body>
+</html>