fix(benchpress): benchpress fixes and a smoke test for Dart

This commit is contained in:
Yegor Jbanov
2015-02-20 17:44:23 -08:00
parent 0a0c0d8302
commit d1f03e509b
18 changed files with 263 additions and 61 deletions

View File

@ -12,5 +12,6 @@ dependencies:
stack_trace: '>=1.1.1 <1.2.0'
angular2:
path: ../angular2
webdriver: ">=0.9.0 <0.10.0"
dev_dependencies:
guinness: ">=0.1.16 <0.2.0"

View File

@ -1,5 +1,5 @@
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
import { isPresent, isBlank, int, BaseException, StringWrapper } from 'angular2/src/facade/lang';
import { isPresent, isBlank, int, BaseException, StringWrapper, Math } from 'angular2/src/facade/lang';
import { ListWrapper, StringMap, StringMapWrapper } from 'angular2/src/facade/collection';
import { bind, OpaqueToken } from 'angular2/di';
@ -95,7 +95,12 @@ export class PerflogMetric extends Metric {
if (needSort) {
// Need to sort because of the ph==='X' events
ListWrapper.sort(this._remainingEvents, (a,b) => {
return a['ts'] - b['ts'];
var diff = a['ts'] - b['ts'];
return diff > 0
? 1
: diff < 0
? -1
: 0;
});
}
}

View File

@ -1,4 +1,4 @@
import { print, isPresent, isBlank } from 'angular2/src/facade/lang';
import { print, isPresent, isBlank, NumberWrapper } from 'angular2/src/facade/lang';
import { StringMapWrapper, ListWrapper, List } from 'angular2/src/facade/collection';
import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
import { Math } from 'angular2/src/facade/math';
@ -28,14 +28,8 @@ export class ConsoleReporter extends Reporter {
return result + value;
}
static _formatNum(num) {
var result;
if (num === 0) {
result = '000';
} else {
result = `${Math.floor(num * 100)}`;
}
return result.substring(0, result.length - 2) + '.' + result.substring(result.length-2);
static _formatNum(n) {
return NumberWrapper.toFixed(n, 2);
}
static _sortedProps(obj) {
@ -89,7 +83,8 @@ export class ConsoleReporter extends Reporter {
var sample = ListWrapper.map(validSample, (measureValues) => measureValues.values[metricName]);
var mean = Statistic.calculateMean(sample);
var cv = Statistic.calculateCoefficientOfVariation(sample, mean);
return `${ConsoleReporter._formatNum(mean)}\u00B1${Math.floor(cv)}%`;
var formattedCv = NumberWrapper.isNaN(cv) ? 'NaN' : Math.floor(cv);
return `${ConsoleReporter._formatNum(mean)}\u00B1${formattedCv}%`;
})
);
return PromiseWrapper.resolve(null);

View File

@ -1,23 +1,32 @@
library benchpress.src.webdriver.async_webdriver_adapter_dart;
import 'package:webdriver/webdriver.dart' show WebDriver, LogEntry;
import 'package:angular2/src/facade/async.dart' show Future;
import '../web_driver_adapter.dart' show WebDriverAdapter;
class AsyncWebDriverAdapter extends WebDriverAdapter {
dynamic _driver;
AsyncWebDriverAdapter(driver) {
this._driver = driver;
}
WebDriver _driver;
AsyncWebDriverAdapter(this._driver);
Future waitFor(Function callback) {
return callback();
}
Future executeScript(String script) {
return this._driver.execute(script);
return _driver.execute(script, const[]);
}
Future capabilities() {
return this._driver.capabilities;
Map capabilities() {
return _driver.capabilities;
}
Future logs(String type) {
return this._driver.logs.get(type);
Future<List<Map>> logs(String type) {
return _driver.logs.get(type)
.map((LogEntry entry) => {
'message': entry.message
})
.fold(<Map>[], (log, Map entry) {
return log..add(entry);
});
}
}