DoYouEvenBench: Indentations in benchmark.js and benchmark.html are all messed up
[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     var storage = [];
117         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
118             element.focus();
119             return element;
120         });
121     },
122     tests: [
123         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
124             var app = contentWindow.app;
125             var fakeEvent = {which: app.ENTER_KEY};
126             for (var i = 0; i < numberOfItemsToAdd; i++) {
127                 newTodo.value = 'Something to do ' + i;
128                 app.create.call(newTodo, fakeEvent);
129                 }
130         }],
131         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
132             var app = contentWindow.app;
133             var checkboxes = contentDocument.querySelectorAll('.toggle');
134             for (var i = 0; i < checkboxes.length; i++)
135             app.toggle.call(checkboxes[i]);
136         }],
137         ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
138             var app = contentWindow.app;
139             var deleteButtons = contentDocument.querySelectorAll('.destroy');
140             for (var i = 0; i < deleteButtons.length; i++)
141             app.destroy.call(deleteButtons[i]);
142         }],
143     ]
144 });
145
146 BenchmarkRunner.suite({
147     name: 'AngularJS/TodoMVC',
148     url: 'todomvc/architecture-examples/angularjs/index.html',
149     prepare: function (contentWindow, contentDocument) {
150     var storage = [];
151         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
152             element.focus();
153             return element;
154         });
155     },
156     tests: [
157         ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
158             var todomvc = contentWindow.todomvc;
159             var submitEvent = document.createEvent('Event');
160             submitEvent.initEvent('submit', true, true);
161             var inputEvent = document.createEvent('Event');
162             inputEvent.initEvent('input', true, true);
163             for (var i = 0; i < numberOfItemsToAdd; i++) {
164                 newTodo.value = 'Something to do ' + i;
165                 newTodo.dispatchEvent(inputEvent);
166                 newTodo.form.dispatchEvent(submitEvent);
167             }
168         }],
169         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
170             var checkboxes = contentDocument.querySelectorAll('.toggle');
171             for (var i = 0; i < checkboxes.length; i++)
172                 checkboxes[i].click();
173         }],
174         ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
175             var deleteButtons = contentDocument.querySelectorAll('.destroy');
176             for (var i = 0; i < deleteButtons.length; i++)
177                 deleteButtons[i].click();
178         }],
179     ]
180 });
181
182 </script>
183 </head>
184 <body>
185 <p></p>
186 </body>
187 </html>