DoYouEvenBench: Make it work on Internet Explorer 11 Release Preview
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / benchmark.html
index b4e2af30dac292e3d57d9b9822eebbcfa060ef18..bb5528988644b73b6028497c754fdad77d726b58 100644 (file)
@@ -19,20 +19,20 @@ BenchmarkRunner.suite({
     tests: [
         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
             var todoController = contentWindow.todo.controller;
-        for (var i = 0; i < numberOfItemsToAdd; i++) {
-            newTodo.value = 'Something to do ' + i;
-            todoController.addItem({keyCode: todoController.ENTER_KEY, target: newTodo});
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                newTodo.value = 'Something to do ' + i;
+                todoController.addItem({keyCode: todoController.ENTER_KEY, target: newTodo});
             }
         }],
         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var checkboxes = contentDocument.querySelectorAll('.toggle');
-        for (var i = 0; i < checkboxes.length; i++)
-            checkboxes[i].click();
+            var checkboxes = contentDocument.querySelectorAll('.toggle');
+            for (var i = 0; i < checkboxes.length; i++)
+                checkboxes[i].click();
         }],
-            ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var deleteButtons = contentDocument.querySelectorAll('.destroy');
-        for (var i = 0; i < deleteButtons.length; i++)
-            deleteButtons[i].click();
+        ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            var deleteButtons = contentDocument.querySelectorAll('.destroy');
+            for (var i = 0; i < deleteButtons.length; i++)
+                deleteButtons[i].click();
         }],
     ]
 });
@@ -41,11 +41,11 @@ BenchmarkRunner.suite({
     name: 'EmberJS/TodoMVC',
     url: 'todomvc/architecture-examples/emberjs/index.html',
     prepare: function (contentWindow, contentDocument) {
-    contentWindow.Todos.Store = contentWindow.DS.Store.extend({
-    revision: 12,
-    adapter: 'Todos.LSAdapter',
-    commit: function () { }
-    });
+        contentWindow.Todos.Store = contentWindow.DS.Store.extend({
+            revision: 12,
+            adapter: 'Todos.LSAdapter',
+            commit: function () { }
+        });
 
         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
             element.focus();
@@ -57,22 +57,22 @@ BenchmarkRunner.suite({
     },
     tests: [
         ['Adding' + numberOfItemsToAdd + 'Items', function (params) {
-        for (var i = 0; i < numberOfItemsToAdd; i++) {
-        params.emberRun(function () { params.views["new-todo"].set('value', 'Something to do' + i); });
-        params.emberRun(function () { params.views["new-todo"].insertNewline(document.createEvent('Event')); });
-        }
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                params.emberRun(function () { params.views["new-todo"].set('value', 'Something to do' + i); });
+                params.emberRun(function () { params.views["new-todo"].insertNewline(document.createEvent('Event')); });
+            }
         }],
         ['CompletingAllItems', function (params, contentWindow, contentDocument) {
-        var checkboxes = contentDocument.querySelectorAll('.ember-checkbox');
-        for (var i = 0; i < checkboxes.length; i++) {
-        var view = params.views[checkboxes[i].id];
-        params.emberRun(function () { view.set('checked', true); });
-        }
+            var checkboxes = contentDocument.querySelectorAll('.ember-checkbox');
+            for (var i = 0; i < checkboxes.length; i++) {
+                var view = params.views[checkboxes[i].id];
+                params.emberRun(function () { view.set('checked', true); });
+            }
         }],
         ['DeletingItems', function (params, contentWindow, contentDocument) {
-        var deleteButtons = contentDocument.querySelectorAll('.destroy');
-        for (var i = 0; i < deleteButtons.length; i++)
-        params.emberRun(function () { deleteButtons[i].click(); });
+            var deleteButtons = contentDocument.querySelectorAll('.destroy');
+            for (var i = 0; i < deleteButtons.length; i++)
+                params.emberRun(function () { deleteButtons[i].click(); });
         }],
     ]
 });
@@ -89,22 +89,22 @@ BenchmarkRunner.suite({
     },
     tests: [
         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
-        var appView = contentWindow.appView;
-        var fakeEvent = {which: contentWindow.ENTER_KEY};
-        for (var i = 0; i < numberOfItemsToAdd; i++) {
-            newTodo.value = 'Something to do ' + i;
-        appView.createOnEnter(fakeEvent);
+            var appView = contentWindow.appView;
+            var fakeEvent = {which: contentWindow.ENTER_KEY};
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                newTodo.value = 'Something to do ' + i;
+                appView.createOnEnter(fakeEvent);
             }
         }],
         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var checkboxes = contentDocument.querySelectorAll('.toggle');
-        for (var i = 0; i < checkboxes.length; i++)
-            checkboxes[i].click();
+            var checkboxes = contentDocument.querySelectorAll('.toggle');
+            for (var i = 0; i < checkboxes.length; i++)
+                checkboxes[i].click();
         }],
-            ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var deleteButtons = contentDocument.querySelectorAll('.destroy');
-        for (var i = 0; i < deleteButtons.length; i++)
-            deleteButtons[i].click();
+        ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            var deleteButtons = contentDocument.querySelectorAll('.destroy');
+            for (var i = 0; i < deleteButtons.length; i++)
+                deleteButtons[i].click();
         }],
     ]
 });
@@ -113,7 +113,6 @@ BenchmarkRunner.suite({
     name: 'jQuery/TodoMVC',
     url: 'todomvc/architecture-examples/jquery/index.html',
     prepare: function (contentWindow, contentDocument) {
-    var storage = [];
         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
             element.focus();
             return element;
@@ -121,24 +120,47 @@ BenchmarkRunner.suite({
     },
     tests: [
         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
-        var app = contentWindow.app;
-        var fakeEvent = {which: app.ENTER_KEY};
-        for (var i = 0; i < numberOfItemsToAdd; i++) {
-            newTodo.value = 'Something to do ' + i;
-        app.create.call(newTodo, fakeEvent);
+            var app = contentWindow.app;
+            var fakeEvent = {which: app.ENTER_KEY};
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                newTodo.value = 'Something to do ' + i;
+                app.create.call(newTodo, fakeEvent);
             }
         }],
         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var app = contentWindow.app;
-        var checkboxes = contentDocument.querySelectorAll('.toggle');
-        for (var i = 0; i < checkboxes.length; i++)
-        app.toggle.call(checkboxes[i]);
+            var app = contentWindow.app;
+            var checkboxes = contentDocument.querySelectorAll('.toggle');
+            var $ = contentWindow.$;
+
+            itemIndexToId = new Array(checkboxes.length);
+            for (var i = 0; i < checkboxes.length; i++)
+                itemIndexToId[i] = $(checkboxes[i]).closest('li').data('id');
+
+            app.getTodo = function (element, callback) {
+                var self = this;
+                var id = itemIndexToId[this.currentItemIndex];
+                $.each(this.todos, function (j, val) {
+                    if (val.id === id) {
+                        callback.apply(self, arguments);
+                        return false;
+                    }
+                });
+            }
+
+            for (var i = 0; i < checkboxes.length; i++) {
+                app.currentItemIndex = i;
+                app.toggle.call(checkboxes[i]);
+            }
         }],
-            ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var app = contentWindow.app;
-        var deleteButtons = contentDocument.querySelectorAll('.destroy');
-        for (var i = 0; i < deleteButtons.length; i++)
-        app.destroy.call(deleteButtons[i]);
+        ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            contentDocument.querySelector('#clear-completed').click();
+            var app = contentWindow.app;
+            var deleteButtons = contentDocument.querySelectorAll('.destroy');
+
+            for (var i = 0; i < deleteButtons.length; i++) {
+                app.currentItemIndex = i;
+                app.destroy.call(deleteButtons[i]);
+            }
         }],
     ]
 });
@@ -147,7 +169,6 @@ BenchmarkRunner.suite({
     name: 'AngularJS/TodoMVC',
     url: 'todomvc/architecture-examples/angularjs/index.html',
     prepare: function (contentWindow, contentDocument) {
-    var storage = [];
         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
             element.focus();
             return element;
@@ -155,26 +176,116 @@ BenchmarkRunner.suite({
     },
     tests: [
         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
-        var todomvc = contentWindow.todomvc;
-        var submitEvent = document.createEvent('Event');
-        submitEvent.initEvent('submit', true, true);
-        var inputEvent = document.createEvent('Event');
-        inputEvent.initEvent('input', true, true);
-        for (var i = 0; i < numberOfItemsToAdd; i++) {
-            newTodo.value = 'Something to do ' + i;
-            newTodo.dispatchEvent(inputEvent);
-            newTodo.form.dispatchEvent(submitEvent);
+            var todomvc = contentWindow.todomvc;
+            var submitEvent = document.createEvent('Event');
+            submitEvent.initEvent('submit', true, true);
+            var inputEvent = document.createEvent('Event');
+            inputEvent.initEvent('input', true, true);
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                newTodo.value = 'Something to do ' + i;
+                newTodo.dispatchEvent(inputEvent);
+                newTodo.form.dispatchEvent(submitEvent);
+            }
+        }],
+        ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            var checkboxes = contentDocument.querySelectorAll('.toggle');
+            for (var i = 0; i < checkboxes.length; i++)
+                checkboxes[i].click();
+        }],
+        ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            var deleteButtons = contentDocument.querySelectorAll('.destroy');
+            for (var i = 0; i < deleteButtons.length; i++)
+                deleteButtons[i].click();
+        }],
+    ]
+});
+
+BenchmarkRunner.suite({
+    name: 'React/TodoMVC',
+    url: 'todomvc/labs/architecture-examples/react/index.html',
+    prepare: function (contentWindow, contentDocument) {
+        contentWindow.Utils.store = function () {}
+        return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
+            element.focus();
+            return element;
+        });
+    },
+    tests: [
+        ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
+            var todomvc = contentWindow.todomvc;
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                newTodo.value = 'Something to do ' + i;
+
+                var keydownEvent = document.createEvent('Event');
+                keydownEvent.initEvent('keydown', true, true);
+                keydownEvent.which = 13; // VK_ENTER
+                newTodo.dispatchEvent(keydownEvent);
             }
         }],
         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var checkboxes = contentDocument.querySelectorAll('.toggle');
-        for (var i = 0; i < checkboxes.length; i++)
-            checkboxes[i].click();
+            var checkboxes = contentDocument.querySelectorAll('.toggle');
+            for (var i = 0; i < checkboxes.length; i++)
+                checkboxes[i].click();
+        }],
+        ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            var deleteButtons = contentDocument.querySelectorAll('.destroy');
+            for (var i = 0; i < deleteButtons.length; i++)
+                deleteButtons[i].click();
+        }],
+    ]
+});
+
+var actionCount = 50;
+BenchmarkRunner.suite({
+    name: 'FlightJS/MailClient',
+    url: 'flightjs-example-app/index.html',
+    prepare: function (contentWindow, contentDocument) {
+        return BenchmarkRunner.waitForElement('.span8').then(function (element) {
+            element.focus();
+            return element;
+        });
+    },
+    tests: [
+        ['OpeningTabs' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
+            contentDocument.getElementById('inbox').click();
+            for (var i = 0; i < actionCount; i++) {
+                contentDocument.getElementById('later').click();
+                contentDocument.getElementById('sent').click();
+                contentDocument.getElementById('trash').click();
+                contentDocument.getElementById('inbox').click();
+            }
         }],
-            ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
-        var deleteButtons = contentDocument.querySelectorAll('.destroy');
-        for (var i = 0; i < deleteButtons.length; i++)
-            deleteButtons[i].click();
+        ['MovingEmails' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
+            contentDocument.getElementById('inbox').click();
+            for (var i = 0; i < actionCount; i++) {
+                contentDocument.getElementById('mail_2139').click();
+                contentDocument.getElementById('move_mail').click();
+                contentDocument.querySelector('#move_to_selector #later').click();
+                contentDocument.getElementById('later').click();
+                contentDocument.getElementById('mail_2139').click();
+                contentDocument.getElementById('move_mail').click();
+                contentDocument.querySelector('#move_to_selector #trash').click();
+                contentDocument.getElementById('trash').click();
+                contentDocument.getElementById('mail_2139').click();
+                contentDocument.getElementById('move_mail').click();
+                contentDocument.querySelector('#move_to_selector #inbox').click();
+                contentDocument.getElementById('inbox').click();
+            }
+        }],
+        ['Sending' + actionCount + 'NewEmails', function (newTodo, contentWindow, contentDocument) {
+            for (var i = 0; i < actionCount; i++) {
+                contentDocument.getElementById('new_mail').click();
+                contentDocument.getElementById('recipient_select').selectedIndex = 1;
+                var subject = contentDocument.getElementById('compose_subject');
+                var message = contentDocument.getElementById('compose_message');
+                subject.focus();
+                contentWindow.$(subject).trigger('keydown');
+                contentWindow.$(subject).text('Hello');
+                message.focus();
+                contentWindow.$(message).trigger('keydown');
+                contentWindow.$(message).text('Hello,\n\nThis is a test message.\n\n- WebKitten');
+                contentDocument.getElementById('send_composed').click();
+            }
         }],
     ]
 });
@@ -182,6 +293,5 @@ BenchmarkRunner.suite({
 </script>
 </head>
 <body>
-<p></p>
 </body>
 </html>