Commit 47d051a4 authored by rniwa@webkit.org's avatar rniwa@webkit.org

DoYouEvenBench: Indentations in benchmark.js and benchmark.html are all messed up

https://bugs.webkit.org/show_bug.cgi?id=121597

Reviewed by Anders Carlsson.

Fixed indentations.

* DoYouEvenBench/benchmark.html:
* DoYouEvenBench/benchmark.js:
(SimplePromise.prototype.resolve.else):
(SimplePromise.prototype.resolve):
(BenchmarkRunner.waitForElement.resolveIfReady):
(BenchmarkRunner.waitForElement):
(BenchmarkRunner._waitAndWarmUp.Fibonacci):
(BenchmarkRunner._finalize):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156104 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bb5605b5
2013-09-19 Ryosuke Niwa <rniwa@webkit.org>
DoYouEvenBench: Indentations in benchmark.js and benchmark.html are all messed up
https://bugs.webkit.org/show_bug.cgi?id=121597
Reviewed by Anders Carlsson.
Fixed indentations.
* DoYouEvenBench/benchmark.html:
* DoYouEvenBench/benchmark.js:
(SimplePromise.prototype.resolve.else):
(SimplePromise.prototype.resolve):
(BenchmarkRunner.waitForElement.resolveIfReady):
(BenchmarkRunner.waitForElement):
(BenchmarkRunner._waitAndWarmUp.Fibonacci):
(BenchmarkRunner._finalize):
2013-09-19 Ryosuke Niwa <rniwa@webkit.org>
Add an AngularJS test to DoYouEvenBench
......
......@@ -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();
}],
]
});
......@@ -121,24 +121,24 @@ 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');
for (var i = 0; i < checkboxes.length; 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) {
var app = contentWindow.app;
var deleteButtons = contentDocument.querySelectorAll('.destroy');
for (var i = 0; i < deleteButtons.length; i++)
app.destroy.call(deleteButtons[i]);
}],
]
});
......@@ -155,26 +155,26 @@ 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();
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();
}],
]
});
......
......@@ -22,15 +22,15 @@ SimplePromise.prototype.resolve = function (value) {
if (!this._callback) {
this._resolved = true;
this._resolvedValue = value;
return;
return;
}
var result = this._callback(value);
if (result instanceof SimplePromise) {
var chainedPromise = this._chainedPromise;
result.then(function (result) { chainedPromise.resolve(result); });
var chainedPromise = this._chainedPromise;
result.then(function (result) { chainedPromise.resolve(result); });
} else
this._chainedPromise.resolve(result);
this._chainedPromise.resolve(result);
}
var BenchmarkRunner = {_suites: [], _prepareReturnValue: null, _measuredValues: {}};
......@@ -47,8 +47,8 @@ BenchmarkRunner.waitForElement = function (selector) {
function resolveIfReady() {
var element = contentDocument.querySelector(selector);
if (element)
return promise.resolve(element);
if (element)
return promise.resolve(element);
setTimeout(resolveIfReady, 50);
}
......@@ -76,19 +76,19 @@ BenchmarkRunner._waitAndWarmUp = function () {
var startTime = Date.now();
function Fibonacci(n) {
if (Date.now() - startTime > 100)
return;
if (n <= 0)
return 0;
else if (n == 1)
return 1;
return Fibonacci(n - 2) + Fibonacci(n - 1);
if (Date.now() - startTime > 100)
return;
if (n <= 0)
return 0;
else if (n == 1)
return 1;
return Fibonacci(n - 2) + Fibonacci(n - 1);
}
var promise = new SimplePromise;
setTimeout(function () {
Fibonacci(100);
promise.resolve();
Fibonacci(100);
promise.resolve();
}, 200);
return promise;
}
......@@ -109,8 +109,8 @@ BenchmarkRunner._runTest = function(suite, testFunction, prepareReturnValue, cal
var startTime = now();
setTimeout(function () {
var endTime = now();
callback(syncTime, endTime - startTime);
var endTime = now();
callback(syncTime, endTime - startTime);
}, 0);
}
......@@ -299,8 +299,8 @@ BenchmarkRunner._finalize = function () {
var results = '';
var total = 0; // FIXME: Compute the total properly.
for (var title in self._measuredValues) {
results += title + ' : ' + self._measuredValues[title] + ' ms\n';
total += self._measuredValues[title];
results += title + ' : ' + self._measuredValues[title] + ' ms\n';
total += self._measuredValues[title];
}
results += 'Total : ' + (total / 2) + ' ms\n';
self._measuredValues = {};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment