Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: client/dom/benchmarks/dromaeo/Dromaeo.dart

Issue 9374026: Move dromaeo to third_party (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moved Dromaeo to third party. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/dom/benchmarks/common/common.dart ('k') | client/dom/benchmarks/dromaeo/Suites.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/benchmarks/dromaeo/Dromaeo.dart
diff --git a/client/dom/benchmarks/dromaeo/Dromaeo.dart b/client/dom/benchmarks/dromaeo/Dromaeo.dart
deleted file mode 100644
index 286568ce88e3e3aaed8cbf76c4021cdb869d8524..0000000000000000000000000000000000000000
--- a/client/dom/benchmarks/dromaeo/Dromaeo.dart
+++ /dev/null
@@ -1,206 +0,0 @@
-#import('dart:dom');
-#import('dart:json');
-#import('Suites.dart');
-
-main() {
- new Dromaeo().run();
-}
-
-class SuiteController {
- final SuiteDescription _suiteDescription;
- final HTMLIFrameElement _suiteIframe;
-
- HTMLDivElement _element;
- double _meanProduct;
- int _nTests;
-
- SuiteController(this._suiteDescription, this._suiteIframe)
- : _meanProduct = 1.0,
- _nTests = 0 {
- _make();
- _init();
- }
-
- start() {
- _suiteIframe.contentWindow.dynamic.postMessage('start', '*');
- }
-
- update(String testName, num mean, num error, double percent) {
- _meanProduct *= mean;
- _nTests++;
-
- final meanAsString = mean.toStringAsFixed(2);
- final errorAsString = error.toStringAsFixed(2);
- final HTMLElement progressDisplay = _element.nextSibling.nextSibling;
- progressDisplay.innerHTML +=
- '<li><b>${testName}:</b>' +
- '${meanAsString}<small> runs/s &#177;${errorAsString}%<small></li>';
- _updateTestPos(percent);
- }
-
- _make() {
- _element = _createDiv('test');
- // TODO(antonm): add an onclick functionality.
- _updateTestPos();
- }
-
- _updateTestPos([double percent = 1.0]) {
- String suiteName = _suiteDescription.name;
- final done = percent >= 100.0;
- String info = '';
- if (done) {
- final parent = _element.parentNode;
- parent.setAttribute('class', parent.getAttribute('class') + ' done');
- final mean = Math.pow(_meanProduct, 1.0 / _nTests).toStringAsFixed(2);
- info = '<span>${mean} runs/s</span>';
- }
- _element.innerHTML =
- '<b>${suiteName}:</b>' +
- '<div class="bar"><div style="width:${percent}%;">${info}</div></div>';
- }
-
- _init() {
- final div = _createDiv('result-item');
- div.appendChild(_element);
- final description = _suiteDescription.description;
- final originUrl = _suiteDescription.origin.url;
- final testUrl = 'tests/' + _suiteDescription.file;
- div.innerHTML +=
- '<p>${description}<br/><a href="${originUrl}">Origin</a>' +
- ', <a href="${testUrl}">Source</a>' +
- '<ol class="results"></ol>';
- // Reread the element, as the previous wrapper get disconnected thanks
- // to .innerHTML update above.
- _element = div.firstChild;
-
- document.getElementById('main').appendChild(div);
- }
-
- HTMLDivElement _createDiv(String clazz) {
- final div = document.createElement('div');
- div.setAttribute('class', clazz);
- return div;
- }
-}
-
-class Dromaeo {
- final List<SuiteController> _suiteControllers;
- Function _handler;
-
- Dromaeo()
- : _suiteControllers = new List<SuiteController>()
- {
- _handler = _createHandler();
- window.addEventListener(
- 'message',
- (MessageEvent event) {
- try {
- final response = JSON.parse(event.data);
- _handler = _handler(response['command'], response['data']);
- } catch (final e, final stacktrace) {
- window.alert('Exception: ${e}: ${stacktrace}');
- }
- },
- false
- );
- }
-
- run() {
- // TODO(antonm): create Re-run tests href.
- final HTMLElement suiteNameElement = _byId('overview').firstChild;
- suiteNameElement.innerHTML = 'DOM Core Tests';
- _css(_byId('tests'), 'display', 'none');
- for (SuiteDescription suite in Suites.SUITE_DESCRIPTIONS) {
- final iframe = document.createElement('iframe');
- _css(iframe, 'height', '1px');
- _css(iframe, 'width', '1px');
- iframe.src = 'tests/' + suite.file;
- document.body.appendChild(iframe);
-
- _suiteControllers.add(new SuiteController(suite, iframe));
- }
- }
-
- static final double _SECS_PER_TEST = 5.0;
-
- Function _createHandler() {
- int suitesLoaded = 0;
- int totalTests = 0;
- int currentSuite;
- double totalTimeSecs, estimatedTimeSecs;
-
- // TODO(jat): Remove void type below. Bug 5269037.
- void _updateTime() {
- final mins = (estimatedTimeSecs / 60).floor().toInt();
- final secs = (estimatedTimeSecs - mins * 60).round().toInt();
- final secsAsString = (secs < 10 ? '0' : '') + secs;
- _byId('left').innerHTML = '${mins}:${secsAsString}';
-
- final elapsed = totalTimeSecs - estimatedTimeSecs;
- final percent = (100 * elapsed / totalTimeSecs).toStringAsFixed(2);
- _css(_byId('timebar'), 'width', '${percent}%');
- }
-
- Function loading, running, done;
-
- loading = (String command, var data) {
- assert(command == 'inited');
- suitesLoaded++;
- totalTests += data['nTests'];
- if (suitesLoaded == _suitesTotal) {
- totalTimeSecs = estimatedTimeSecs = _SECS_PER_TEST * totalTests;
- _updateTime();
- currentSuite = 0;
- _suiteControllers[currentSuite].start();
- return running;
- }
-
- return loading;
- };
-
- running = (String command, var data) {
- switch (command) {
- case 'result':
- final testName = data['testName'];
- final mean = data['mean'];
- final error = data['error'];
- final percent = data['percent'];
- _suiteControllers[currentSuite].update(testName, mean, error, percent);
- estimatedTimeSecs -= _SECS_PER_TEST;
- _updateTime();
- return running;
-
- case 'over':
- currentSuite++;
- if (currentSuite < _suitesTotal) {
- _suiteControllers[currentSuite].start();
- return running;
- }
- document.body.setAttribute('class', 'alldone');
- return done;
-
- default:
- throw 'Unknown command ${command} [${data}]';
- }
- };
-
- done = (String command, var data) {
- };
-
- return loading;
- }
-
- _css(Element element, String property, String value) {
- // TODO(antonm): remove the last argument when CallWithDefaultValue
- // is implemented.
- element.style.setProperty(property, value, '');
- }
-
- HTMLElement _byId(String id) {
- return document.getElementById(id);
- }
-
- int get _suitesTotal() {
- return _suiteControllers.length;
- }
-}
« no previous file with comments | « client/dom/benchmarks/common/common.dart ('k') | client/dom/benchmarks/dromaeo/Suites.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698