DoYouEvenBench: Add a test case for FlightJS
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / benchmark.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>DoYouEvenBench</title>
5 <script src="benchmark.js"></script>
6 <script>
7
8 var numberOfItemsToAdd = 100;
9
10 BenchmarkRunner.suite({
11     name: 'VanillaJS/TodoMVC',
12     url: 'todomvc/vanilla-examples/vanillajs/index.html',
13     prepare: function (contentWindow, contentDocument) {
14         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
15             element.focus();
16             return element;
17         });
18     },
19     tests: [
20         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
21             var todoController = contentWindow.todo.controller;
22             for (var i = 0; i < numberOfItemsToAdd; i++) {
23                 newTodo.value = 'Something to do ' + i;
24                 todoController.addItem({keyCode: todoController.ENTER_KEY, target: newTodo});
25             }
26         }],
27         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
28             var checkboxes = contentDocument.querySelectorAll('.toggle');
29             for (var i = 0; i < checkboxes.length; i++)
30                 checkboxes[i].click();
31         }],
32         ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
33             var deleteButtons = contentDocument.querySelectorAll('.destroy');
34             for (var i = 0; i < deleteButtons.length; i++)
35                 deleteButtons[i].click();
36         }],
37     ]
38 });
39
40 BenchmarkRunner.suite({
41     name: 'EmberJS/TodoMVC',
42     url: 'todomvc/architecture-examples/emberjs/index.html',
43     prepare: function (contentWindow, contentDocument) {
44         contentWindow.Todos.Store = contentWindow.DS.Store.extend({
45             revision: 12,
46             adapter: 'Todos.LSAdapter',
47             commit: function () { }
48         });
49
50         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
51             element.focus();
52             return {
53                 views: contentWindow.Ember.View.views,
54                 emberRun: contentWindow.Ember.run,
55             }
56         });
57     },
58     tests: [
59         ['Adding' + numberOfItemsToAdd + 'Items', function (params) {
60             for (var i = 0; i < numberOfItemsToAdd; i++) {
61                 params.emberRun(function () { params.views["new-todo"].set('value', 'Something to do' + i); });
62                 params.emberRun(function () { params.views["new-todo"].insertNewline(document.createEvent('Event')); });
63             }
64         }],
65         ['CompletingAllItems', function (params, contentWindow, contentDocument) {
66             var checkboxes = contentDocument.querySelectorAll('.ember-checkbox');
67             for (var i = 0; i < checkboxes.length; i++) {
68                 var view = params.views[checkboxes[i].id];
69                 params.emberRun(function () { view.set('checked', true); });
70             }
71         }],
72         ['DeletingItems', function (params, contentWindow, contentDocument) {
73             var deleteButtons = contentDocument.querySelectorAll('.destroy');
74             for (var i = 0; i < deleteButtons.length; i++)
75                 params.emberRun(function () { deleteButtons[i].click(); });
76         }],
77     ]
78 });
79
80 BenchmarkRunner.suite({
81     name: 'BackboneJS/TodoMVC',
82     url: 'todomvc/architecture-examples/backbone/index.html',
83     prepare: function (contentWindow, contentDocument) {
84     contentWindow.Backbone.sync = function () {}
85         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
86             element.focus();
87             return element;
88         });
89     },
90     tests: [
91         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
92             var appView = contentWindow.appView;
93             var fakeEvent = {which: contentWindow.ENTER_KEY};
94             for (var i = 0; i < numberOfItemsToAdd; i++) {
95                 newTodo.value = 'Something to do ' + i;
96                 appView.createOnEnter(fakeEvent);
97             }
98         }],
99         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
100             var checkboxes = contentDocument.querySelectorAll('.toggle');
101             for (var i = 0; i < checkboxes.length; i++)
102                 checkboxes[i].click();
103         }],
104         ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
105             var deleteButtons = contentDocument.querySelectorAll('.destroy');
106             for (var i = 0; i < deleteButtons.length; i++)
107                 deleteButtons[i].click();
108         }],
109     ]
110 });
111
112 BenchmarkRunner.suite({
113     name: 'jQuery/TodoMVC',
114     url: 'todomvc/architecture-examples/jquery/index.html',
115     prepare: function (contentWindow, contentDocument) {
116         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
117             element.focus();
118             return element;
119         });
120     },
121     tests: [
122         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
123             var app = contentWindow.app;
124             var fakeEvent = {which: app.ENTER_KEY};
125             for (var i = 0; i < numberOfItemsToAdd; i++) {
126                 newTodo.value = 'Something to do ' + i;
127                 app.create.call(newTodo, fakeEvent);
128                 }
129         }],
130         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
131             var app = contentWindow.app;
132             var checkboxes = contentDocument.querySelectorAll('.toggle');
133             for (var i = 0; i < checkboxes.length; i++)
134             app.toggle.call(checkboxes[i]);
135         }],
136         ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
137             var app = contentWindow.app;
138             var deleteButtons = contentDocument.querySelectorAll('.destroy');
139             for (var i = 0; i < deleteButtons.length; i++)
140             app.destroy.call(deleteButtons[i]);
141         }],
142     ]
143 });
144
145 BenchmarkRunner.suite({
146     name: 'AngularJS/TodoMVC',
147     url: 'todomvc/architecture-examples/angularjs/index.html',
148     prepare: function (contentWindow, contentDocument) {
149         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
150             element.focus();
151             return element;
152         });
153     },
154     tests: [
155         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
156             var todomvc = contentWindow.todomvc;
157             var submitEvent = document.createEvent('Event');
158             submitEvent.initEvent('submit', true, true);
159             var inputEvent = document.createEvent('Event');
160             inputEvent.initEvent('input', true, true);
161             for (var i = 0; i < numberOfItemsToAdd; i++) {
162                 newTodo.value = 'Something to do ' + i;
163                 newTodo.dispatchEvent(inputEvent);
164                 newTodo.form.dispatchEvent(submitEvent);
165             }
166         }],
167         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
168             var checkboxes = contentDocument.querySelectorAll('.toggle');
169             for (var i = 0; i < checkboxes.length; i++)
170                 checkboxes[i].click();
171         }],
172         ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
173             var deleteButtons = contentDocument.querySelectorAll('.destroy');
174             for (var i = 0; i < deleteButtons.length; i++)
175                 deleteButtons[i].click();
176         }],
177     ]
178 });
179
180 var actionCount = 50;
181 BenchmarkRunner.suite({
182     name: 'FlightJS/MailClient',
183     url: 'flightjs-example-app/index.html',
184     prepare: function (contentWindow, contentDocument) {
185         return BenchmarkRunner.waitForElement('.span8').then(function (element) {
186             element.focus();
187             return element;
188         });
189     },
190     tests: [
191         ['OpeningTabs' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
192             contentDocument.getElementById('inbox').click();
193             for (var i = 0; i < actionCount; i++) {
194                 contentDocument.getElementById('later').click();
195                 contentDocument.getElementById('sent').click();
196                 contentDocument.getElementById('trash').click();
197                 contentDocument.getElementById('inbox').click();
198             }
199         }],
200         ['MovingEmails' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
201             contentDocument.getElementById('inbox').click();
202             for (var i = 0; i < actionCount; i++) {
203                 contentDocument.getElementById('mail_2139').click();
204                 contentDocument.getElementById('move_mail').click();
205                 contentDocument.querySelector('#move_to_selector #later').click();
206                 contentDocument.getElementById('later').click();
207                 contentDocument.getElementById('mail_2139').click();
208                 contentDocument.getElementById('move_mail').click();
209                 contentDocument.querySelector('#move_to_selector #trash').click();
210                 contentDocument.getElementById('trash').click();
211                 contentDocument.getElementById('mail_2139').click();
212                 contentDocument.getElementById('move_mail').click();
213                 contentDocument.querySelector('#move_to_selector #inbox').click();
214                 contentDocument.getElementById('inbox').click();
215             }
216         }],
217         ['Sending' + actionCount + 'NewEmails', function (newTodo, contentWindow, contentDocument) {
218             for (var i = 0; i < actionCount; i++) {
219                 contentDocument.getElementById('new_mail').click();
220                 var subject = contentDocument.getElementById('compose_subject');
221                 var message = contentDocument.getElementById('compose_message');
222                 subject.focus();
223                 contentWindow.$(subject).trigger('keydown');
224                 contentDocument.execCommand('InsertText', false, 'Hello');
225                 message.focus();
226                 contentWindow.$(message).trigger('keydown');
227                 contentDocument.execCommand('InsertText', false, 'Hello,\n\nThis is a test message.\n\n- WebKitten');
228                 contentDocument.getElementById('send_composed').click();
229             }
230         }],
231     ]
232 });
233
234 </script>
235 </head>
236 <body>
237 </body>
238 </html>