diff --git a/gulpfile.js b/gulpfile.js
index e0f982a67b..e0873d581c 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -475,7 +475,7 @@ gulp.task('test.unit.dart/ci', function (done) {
gulp.task('test.unit.cjs/ci', function(done) {
- runJasmineTests(['dist/js/cjs/angular2/test/**/*_spec.js'], done);
+ runJasmineTests(['dist/js/cjs/{angular2,benchpress}/test/**/*_spec.js'], done);
});
diff --git a/modules/angular2/src/facade/lang.ts b/modules/angular2/src/facade/lang.ts
index 357fce3b03..bb5982a119 100644
--- a/modules/angular2/src/facade/lang.ts
+++ b/modules/angular2/src/facade/lang.ts
@@ -43,7 +43,9 @@ export function CONST() {
return (target) => target;
}
-export class ABSTRACT {}
+export function ABSTRACT() {
+ return (t) => t;
+}
// Note: This is only a marker annotation needed for ts2dart.
// This is written so that is can be used as a Traceur annotation
diff --git a/modules/benchpress/benchpress.es6 b/modules/benchpress/benchpress.ts
similarity index 59%
rename from modules/benchpress/benchpress.es6
rename to modules/benchpress/benchpress.ts
index 7b1f0f23f2..7215e59dd3 100644
--- a/modules/benchpress/benchpress.es6
+++ b/modules/benchpress/benchpress.ts
@@ -1,8 +1,10 @@
-import { bind } from 'angular2/di';
-import { Options } from './common';
+///
+
+import {bind} from 'angular2/di';
+import {Options} from './common';
export * from './common';
-export { SeleniumWebDriverAdapter } from './src/webdriver/selenium_webdriver_adapter';
+export {SeleniumWebDriverAdapter} from './src/webdriver/selenium_webdriver_adapter';
var fs = require('fs');
@@ -11,11 +13,9 @@ var fs = require('fs');
// find another way...
// Note: Can't do the `require` call in a facade as it can't be loaded into the browser
// for our unit tests via karma.
-Options.DEFAULT_BINDINGS.push(
- bind(Options.WRITE_FILE).toValue(writeFile)
-);
+Options.DEFAULT_BINDINGS.push(bind(Options.WRITE_FILE).toValue(writeFile));
-function writeFile(filename, content) {
+function writeFile(filename, content): Promise {
return new Promise(function(resolve, reject) {
fs.writeFile(filename, content, (error) => {
if (error) {
diff --git a/modules/benchpress/common.js b/modules/benchpress/common.js
deleted file mode 100644
index 0da19f38f2..0000000000
--- a/modules/benchpress/common.js
+++ /dev/null
@@ -1,21 +0,0 @@
-export { Sampler, SampleState } from './src/sampler';
-export { Metric } from './src/metric';
-export { Validator } from './src/validator';
-export { Reporter } from './src/reporter';
-export { WebDriverExtension, PerfLogFeatures } from './src/web_driver_extension';
-export { WebDriverAdapter } from './src/web_driver_adapter';
-export { SizeValidator } from './src/validator/size_validator';
-export { RegressionSlopeValidator } from './src/validator/regression_slope_validator';
-export { ConsoleReporter } from './src/reporter/console_reporter';
-export { JsonFileReporter } from './src/reporter/json_file_reporter';
-export { SampleDescription } from './src/sample_description';
-export { PerflogMetric } from './src/metric/perflog_metric';
-export { ChromeDriverExtension } from './src/webdriver/chrome_driver_extension';
-export { IOsDriverExtension } from './src/webdriver/ios_driver_extension';
-export { Runner } from './src/runner';
-export { Options } from './src/common_options';
-export { MeasureValues } from './src/measure_values';
-export { MultiMetric } from './src/metric/multi_metric';
-export { MultiReporter } from './src/reporter/multi_reporter';
-
-export { bind, Injector, OpaqueToken } from 'angular2/di';
diff --git a/modules/benchpress/common.ts b/modules/benchpress/common.ts
new file mode 100644
index 0000000000..36460ea5d3
--- /dev/null
+++ b/modules/benchpress/common.ts
@@ -0,0 +1,21 @@
+export {Sampler, SampleState} from './src/sampler';
+export {Metric} from './src/metric';
+export {Validator} from './src/validator';
+export {Reporter} from './src/reporter';
+export {WebDriverExtension, PerfLogFeatures} from './src/web_driver_extension';
+export {WebDriverAdapter} from './src/web_driver_adapter';
+export {SizeValidator} from './src/validator/size_validator';
+export {RegressionSlopeValidator} from './src/validator/regression_slope_validator';
+export {ConsoleReporter} from './src/reporter/console_reporter';
+export {JsonFileReporter} from './src/reporter/json_file_reporter';
+export {SampleDescription} from './src/sample_description';
+export {PerflogMetric} from './src/metric/perflog_metric';
+export {ChromeDriverExtension} from './src/webdriver/chrome_driver_extension';
+export {IOsDriverExtension} from './src/webdriver/ios_driver_extension';
+export {Runner} from './src/runner';
+export {Options} from './src/common_options';
+export {MeasureValues} from './src/measure_values';
+export {MultiMetric} from './src/metric/multi_metric';
+export {MultiReporter} from './src/reporter/multi_reporter';
+
+export {bind, Injector, OpaqueToken} from 'angular2/di';
diff --git a/modules/benchpress/index.cjs b/modules/benchpress/index.cjs
deleted file mode 100644
index c4dc17cbd6..0000000000
--- a/modules/benchpress/index.cjs
+++ /dev/null
@@ -1,2 +0,0 @@
-require(require('traceur').RUNTIME_PATH);
-module.exports = require('./benchpress.js');
diff --git a/modules/benchpress/src/common_options.js b/modules/benchpress/src/common_options.ts
similarity index 91%
rename from modules/benchpress/src/common_options.js
rename to modules/benchpress/src/common_options.ts
index be4936163f..f4810bfb03 100644
--- a/modules/benchpress/src/common_options.js
+++ b/modules/benchpress/src/common_options.ts
@@ -1,5 +1,5 @@
-import { bind, OpaqueToken } from 'angular2/di';
-import { DateWrapper } from 'angular2/src/facade/lang';
+import {bind, OpaqueToken} from 'angular2/di';
+import {DateWrapper} from 'angular2/src/facade/lang';
export class Options {
static get DEFAULT_BINDINGS() { return _DEFAULT_BINDINGS; }
@@ -40,10 +40,11 @@ var _NOW = new OpaqueToken('Options.now');
var _WRITE_FILE = new OpaqueToken('Options.writeFile');
var _DEFAULT_BINDINGS = [
- bind(_DEFAULT_DESCRIPTION).toValue({}),
+ bind(_DEFAULT_DESCRIPTION)
+ .toValue({}),
bind(_SAMPLE_DESCRIPTION).toValue({}),
bind(_FORCE_GC).toValue(false),
bind(_PREPARE).toValue(false),
bind(_MICRO_METRICS).toValue({}),
- bind(_NOW).toValue( () => DateWrapper.now() )
-];
\ No newline at end of file
+ bind(_NOW).toValue(() => DateWrapper.now())
+];
diff --git a/modules/benchpress/src/firefox_extension/data/installed_script.dart b/modules/benchpress/src/firefox_extension/data/installed_script.dart
new file mode 100644
index 0000000000..4a36357121
--- /dev/null
+++ b/modules/benchpress/src/firefox_extension/data/installed_script.dart
@@ -0,0 +1,2 @@
+library benchpress.src.firefox_extension.data.installed_script;
+//no dart implementation
diff --git a/modules/benchpress/src/firefox_extension/data/installed_script.es6 b/modules/benchpress/src/firefox_extension/data/installed_script.es6
deleted file mode 100644
index 88cc250371..0000000000
--- a/modules/benchpress/src/firefox_extension/data/installed_script.es6
+++ /dev/null
@@ -1,12 +0,0 @@
-exportFunction(function() {
- self.port.emit('startProfiler');
-}, unsafeWindow, {defineAs: "startProfiler"});
-
-exportFunction(function(filePath) {
- self.port.emit('stopAndRecord', filePath);
-}, unsafeWindow, {defineAs: "stopAndRecord"});
-
-exportFunction(function() {
- self.port.emit('forceGC');
-}, unsafeWindow, {defineAs: "forceGC"});
-
diff --git a/modules/benchpress/src/firefox_extension/data/installed_script.ts b/modules/benchpress/src/firefox_extension/data/installed_script.ts
new file mode 100644
index 0000000000..d758c9bc7b
--- /dev/null
+++ b/modules/benchpress/src/firefox_extension/data/installed_script.ts
@@ -0,0 +1,11 @@
+declare var exportFunction;
+declare var unsafeWindow;
+
+exportFunction(function() { (self).port.emit('startProfiler'); }, unsafeWindow,
+ {defineAs: "startProfiler"});
+
+exportFunction(function(filePath) { (self).port.emit('stopAndRecord', filePath); },
+ unsafeWindow, {defineAs: "stopAndRecord"});
+
+exportFunction(function() { (self).port.emit('forceGC'); }, unsafeWindow,
+ {defineAs: "forceGC"});
diff --git a/modules/benchpress/src/firefox_extension/lib/main.dart b/modules/benchpress/src/firefox_extension/lib/main.dart
new file mode 100644
index 0000000000..81e92e6923
--- /dev/null
+++ b/modules/benchpress/src/firefox_extension/lib/main.dart
@@ -0,0 +1,2 @@
+library benchpress.src.firefox_extension.lib.main;
+//no dart implementation
diff --git a/modules/benchpress/src/firefox_extension/lib/main.es6 b/modules/benchpress/src/firefox_extension/lib/main.es6
deleted file mode 100644
index ecfb56488f..0000000000
--- a/modules/benchpress/src/firefox_extension/lib/main.es6
+++ /dev/null
@@ -1,61 +0,0 @@
-var file = require('sdk/io/file');
-var {Cc,Ci,Cu} = require("chrome");
-
-function Profiler() {
- this._profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
-};
-
-Profiler.prototype = {
- start: function(entries, interval, features) {
- this._profiler.StartProfiler(entries, interval, features, features.length);
- },
- stop: function(cb) {
- this._profiler.StopProfiler();
- // this.gcStats.clear();
- },
- getProfileData: function() {
- return this._profiler.getProfileData();
- }
-};
-
-function saveToFile(savePath, str) {
- var textWriter = file.open(savePath, 'w');
- textWriter.write(str);
- textWriter.close();
-}
-
-function forceGC() {
- Cu.forceGC();
- var os = Cc["@mozilla.org/observer-service;1"]
- .getService(Ci.nsIObserverService);
- os.notifyObservers(null, "child-gc-request", null);
-}
-
-var profiler = new Profiler();
-function startProfiler() {
- profiler.start(/* = profiler memory */ 10000000, 1, ['leaf', 'js', "stackwalk", 'gc']);
-};
-function stopAndRecord(filePath) {
- var profileData = profiler.getProfileData();
- profiler.stop();
- saveToFile(filePath, JSON.stringify(profileData, null, 2));
-};
-
-
-var mod = require("sdk/page-mod");
-var data = require("sdk/self").data;
-mod.PageMod({
- include: ['*'],
- contentScriptFile: data.url("installed_script.js"),
- onAttach: function(worker) {
- worker.port.on('startProfiler', function() {
- startProfiler();
- });
- worker.port.on('stopAndRecord', function(filePath) {
- stopAndRecord(filePath);
- });
- worker.port.on('forceGC', function() {
- forceGC();
- });
- }
-});
diff --git a/modules/benchpress/src/firefox_extension/lib/main.ts b/modules/benchpress/src/firefox_extension/lib/main.ts
new file mode 100644
index 0000000000..4d71fe056c
--- /dev/null
+++ b/modules/benchpress/src/firefox_extension/lib/main.ts
@@ -0,0 +1,53 @@
+///
+
+var file = require('sdk/io/file');
+var {Cc, Ci, Cu} = require("chrome");
+
+class Profiler {
+ private _profiler;
+ constructor() { this._profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); }
+
+ start(entries, interval, features) {
+ this._profiler.StartProfiler(entries, interval, features, features.length);
+ }
+
+ stop() { this._profiler.StopProfiler(); }
+ getProfileData() { return this._profiler.getProfileData(); }
+}
+
+
+function saveToFile(savePath: string, body: string) {
+ var textWriter = file.open(savePath, 'w');
+ textWriter.write(body);
+ textWriter.close();
+}
+
+function forceGC() {
+ Cu.forceGC();
+ var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+ os.notifyObservers(null, "child-gc-request", null);
+}
+
+var profiler = new Profiler();
+function startProfiler() {
+ profiler.start(/* = profiler memory */ 10000000, 1, ['leaf', 'js', "stackwalk", 'gc']);
+};
+function stopAndRecord(filePath) {
+ var profileData = profiler.getProfileData();
+ profiler.stop();
+ saveToFile(filePath, JSON.stringify(profileData, null, 2));
+};
+
+
+var mod = require("sdk/page-mod");
+var data = require("sdk/self").data;
+mod.PageMod({
+ include: ['*'],
+ contentScriptFile: data.url("installed_script.js"),
+ onAttach: worker =>
+ {
+ worker.port.on('startProfiler', () => startProfiler());
+ worker.port.on('stopAndRecord', filePath => stopAndRecord(filePath));
+ worker.port.on('forceGC', () => forceGC());
+ }
+});
diff --git a/modules/benchpress/src/firefox_extension/lib/test_helper.dart b/modules/benchpress/src/firefox_extension/lib/test_helper.dart
new file mode 100644
index 0000000000..ff67437610
--- /dev/null
+++ b/modules/benchpress/src/firefox_extension/lib/test_helper.dart
@@ -0,0 +1,2 @@
+library benchpress.src.firefox_extension.lib.test_helper;
+//no dart implementation
diff --git a/modules/benchpress/src/firefox_extension/lib/test_helper.es6 b/modules/benchpress/src/firefox_extension/lib/test_helper.ts
similarity index 72%
rename from modules/benchpress/src/firefox_extension/lib/test_helper.es6
rename to modules/benchpress/src/firefox_extension/lib/test_helper.ts
index ee3eea4bc1..b1bb5ff7e5 100644
--- a/modules/benchpress/src/firefox_extension/lib/test_helper.es6
+++ b/modules/benchpress/src/firefox_extension/lib/test_helper.ts
@@ -19,12 +19,9 @@ exports.getFirefoxProfile = function(extensionPath) {
var deferred = q.defer();
var firefoxProfile = new FirefoxProfile();
- firefoxProfile.addExtensions([extensionPath], function() {
- firefoxProfile.encoded(function(encodedProfile) {
- var multiCapabilities = [{
- browserName: 'firefox',
- firefox_profile : encodedProfile
- }];
+ firefoxProfile.addExtensions([extensionPath], () => {
+ firefoxProfile.encoded(encodedProfile => {
+ var multiCapabilities = [{browserName: 'firefox', firefox_profile: encodedProfile}];
deferred.resolve(multiCapabilities);
});
});
@@ -39,9 +36,9 @@ exports.getFirefoxProfileWithExtension = function() {
var savedCwd = process.cwd();
process.chdir(absPackageJsonDir);
- return jpm(packageJson).then(function(xpiPath) {
- process.chdir(savedCwd);
- return exports.getFirefoxProfile(xpiPath);
- });
+ return jpm(packageJson)
+ .then(xpiPath => {
+ process.chdir(savedCwd);
+ return exports.getFirefoxProfile(xpiPath);
+ });
};
-
diff --git a/modules/benchpress/src/measure_values.js b/modules/benchpress/src/measure_values.js
deleted file mode 100644
index 89ed03c91a..0000000000
--- a/modules/benchpress/src/measure_values.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Date, DateWrapper } from 'angular2/src/facade/lang';
-import { StringMap } from 'angular2/src/facade/collection';
-
-export class MeasureValues {
- timeStamp:Date;
- runIndex:number;
- values:StringMap;
-
- constructor(runIndex:number, timeStamp:Date, values:StringMap) {
- this.timeStamp = timeStamp;
- this.runIndex = runIndex;
- this.values = values;
- }
-
- toJson() {
- return {
- 'timeStamp': DateWrapper.toJson(this.timeStamp),
- 'runIndex': this.runIndex,
- 'values': this.values
- };
- }
-}
diff --git a/modules/benchpress/src/measure_values.ts b/modules/benchpress/src/measure_values.ts
new file mode 100644
index 0000000000..bdacf455e2
--- /dev/null
+++ b/modules/benchpress/src/measure_values.ts
@@ -0,0 +1,15 @@
+import {Date, DateWrapper} from 'angular2/src/facade/lang';
+import {StringMap, Map} from 'angular2/src/facade/collection';
+
+export class MeasureValues {
+ constructor(public runIndex: number, public timeStamp: Date,
+ public values: StringMap) {}
+
+ toJson() {
+ return {
+ 'timeStamp': DateWrapper.toJson(this.timeStamp),
+ 'runIndex': this.runIndex,
+ 'values': this.values
+ };
+ }
+}
diff --git a/modules/benchpress/src/metric.js b/modules/benchpress/src/metric.js
deleted file mode 100644
index 23e11d3854..0000000000
--- a/modules/benchpress/src/metric.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import { bind } from 'angular2/di';
-import {
- Promise, PromiseWrapper
-} from 'angular2/src/facade/async';
-import {
- ABSTRACT, BaseException
-} from 'angular2/src/facade/lang';
-import { StringMap } from 'angular2/src/facade/collection';
-
-/**
- * A metric is measures values
- */
-@ABSTRACT()
-export class Metric {
- static bindTo(delegateToken) {
- return [
- bind(Metric).toFactory(
- (delegate) => delegate, [delegateToken]
- )
- ];
- }
-
- /**
- * Starts measuring
- */
- beginMeasure():Promise {
- throw new BaseException('NYI');
- }
-
- /**
- * Ends measuring and reports the data
- * since the begin call.
- * @param restart: Whether to restart right after this.
- */
- endMeasure(restart:boolean):Promise {
- throw new BaseException('NYI');
- }
-
- /**
- * Describes the metrics provided by this metric implementation.
- * (e.g. units, ...)
- */
- describe():StringMap {
- throw new BaseException('NYI');
- }
-}
diff --git a/modules/benchpress/src/metric.ts b/modules/benchpress/src/metric.ts
new file mode 100644
index 0000000000..6b3c6f38e7
--- /dev/null
+++ b/modules/benchpress/src/metric.ts
@@ -0,0 +1,32 @@
+import {bind} from 'angular2/di';
+import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
+import {ABSTRACT, BaseException} from 'angular2/src/facade/lang';
+import {StringMap} from 'angular2/src/facade/collection';
+
+/**
+ * A metric is measures values
+ */
+@ABSTRACT()
+export class Metric {
+ static bindTo(delegateToken) {
+ return [bind(Metric).toFactory((delegate) => delegate, [delegateToken])];
+ }
+
+ /**
+ * Starts measuring
+ */
+ beginMeasure(): Promise { throw new BaseException('NYI'); }
+
+ /**
+ * Ends measuring and reports the data
+ * since the begin call.
+ * @param restart: Whether to restart right after this.
+ */
+ endMeasure(restart: boolean): Promise> { throw new BaseException('NYI'); }
+
+ /**
+ * Describes the metrics provided by this metric implementation.
+ * (e.g. units, ...)
+ */
+ describe(): StringMap { throw new BaseException('NYI'); }
+}
diff --git a/modules/benchpress/src/metric/multi_metric.js b/modules/benchpress/src/metric/multi_metric.js
deleted file mode 100644
index 99cde83c2d..0000000000
--- a/modules/benchpress/src/metric/multi_metric.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { bind, Injector, OpaqueToken } from 'angular2/di';
-import { List, ListWrapper, StringMapWrapper, StringMap } from 'angular2/src/facade/collection';
-import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
-
-import { Metric } from '../metric';
-
-export class MultiMetric extends Metric {
- static createBindings(childTokens) {
- return [
- bind(_CHILDREN).toAsyncFactory(
- (injector) => PromiseWrapper.all(ListWrapper.map(childTokens, (token) => injector.asyncGet(token) )),
- [Injector]
- ),
- bind(MultiMetric).toFactory(
- (children) => new MultiMetric(children),
- [_CHILDREN]
- )
- ];
- }
-
- _metrics:List;
-
- constructor(metrics) {
- super();
- this._metrics = metrics;
- }
-
- /**
- * Starts measuring
- */
- beginMeasure():Promise {
- return PromiseWrapper.all(ListWrapper.map(
- this._metrics, (metric) => metric.beginMeasure()
- ));
- }
-
- /**
- * Ends measuring and reports the data
- * since the begin call.
- * @param restart: Whether to restart right after this.
- */
- endMeasure(restart:boolean):Promise {
- return PromiseWrapper.all(ListWrapper.map(
- this._metrics, (metric) => metric.endMeasure(restart)
- )).then( (values) => {
- return mergeStringMaps(values);
- });
- }
-
- /**
- * Describes the metrics provided by this metric implementation.
- * (e.g. units, ...)
- */
- describe():StringMap {
- return mergeStringMaps(this._metrics.map( (metric) => metric.describe() ));
- }
-}
-
-function mergeStringMaps(maps) {
- var result = {};
- ListWrapper.forEach(maps, (map) => {
- StringMapWrapper.forEach(map, (value, prop) => {
- result[prop] = value;
- });
- });
- return result;
-}
-
-var _CHILDREN = new OpaqueToken('MultiMetric.children');
diff --git a/modules/benchpress/src/metric/multi_metric.ts b/modules/benchpress/src/metric/multi_metric.ts
new file mode 100644
index 0000000000..1b14857df0
--- /dev/null
+++ b/modules/benchpress/src/metric/multi_metric.ts
@@ -0,0 +1,55 @@
+import {bind, Binding, Injector, OpaqueToken} from 'angular2/di';
+import {List, ListWrapper, StringMapWrapper, StringMap} from 'angular2/src/facade/collection';
+import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
+
+import {Metric} from '../metric';
+
+export class MultiMetric extends Metric {
+ static createBindings(childTokens): List {
+ return [
+ bind(_CHILDREN)
+ .toAsyncFactory((injector) => PromiseWrapper.all(
+ ListWrapper.map(childTokens, (token) => injector.asyncGet(token))),
+ [Injector]),
+ bind(MultiMetric).toFactory((children) => new MultiMetric(children), [_CHILDREN])
+ ];
+ }
+
+ constructor(private _metrics: List) { super(); }
+
+ /**
+ * Starts measuring
+ */
+ beginMeasure(): Promise {
+ return PromiseWrapper.all(ListWrapper.map(this._metrics, (metric) => metric.beginMeasure()));
+ }
+
+ /**
+ * Ends measuring and reports the data
+ * since the begin call.
+ * @param restart: Whether to restart right after this.
+ */
+ endMeasure(restart: boolean): Promise> {
+ return PromiseWrapper.all(
+ ListWrapper.map(this._metrics, (metric) => metric.endMeasure(restart)))
+ .then((values) => { return mergeStringMaps(values); });
+ }
+
+ /**
+ * Describes the metrics provided by this metric implementation.
+ * (e.g. units, ...)
+ */
+ describe(): StringMap {
+ return mergeStringMaps(this._metrics.map((metric) => metric.describe()));
+ }
+}
+
+function mergeStringMaps(maps): Object {
+ var result = {};
+ ListWrapper.forEach(maps, (map) => {
+ StringMapWrapper.forEach(map, (value, prop) => { result[prop] = value; });
+ });
+ return result;
+}
+
+var _CHILDREN = new OpaqueToken('MultiMetric.children');
diff --git a/modules/benchpress/src/metric/perflog_metric.js b/modules/benchpress/src/metric/perflog_metric.ts
similarity index 60%
rename from modules/benchpress/src/metric/perflog_metric.js
rename to modules/benchpress/src/metric/perflog_metric.ts
index d929e5f8cc..304a845311 100644
--- a/modules/benchpress/src/metric/perflog_metric.js
+++ b/modules/benchpress/src/metric/perflog_metric.ts
@@ -1,48 +1,49 @@
-import { PromiseWrapper, Promise, TimerWrapper } from 'angular2/src/facade/async';
+import {PromiseWrapper, Promise, TimerWrapper} from 'angular2/src/facade/async';
import {
- isPresent, isBlank, int, BaseException, StringWrapper, Math, RegExpWrapper, NumberWrapper
+ isPresent,
+ isBlank,
+ BaseException,
+ StringWrapper,
+ Math,
+ RegExpWrapper,
+ NumberWrapper
} from 'angular2/src/facade/lang';
-import { ListWrapper, StringMap, StringMapWrapper } from 'angular2/src/facade/collection';
-import { bind, OpaqueToken } from 'angular2/di';
+import {ListWrapper, StringMap, StringMapWrapper} from 'angular2/src/facade/collection';
+import {bind, Binding, OpaqueToken} from 'angular2/di';
-import { WebDriverExtension, PerfLogFeatures } from '../web_driver_extension';
-import { Metric } from '../metric';
-import { Options } from '../common_options';
+import {WebDriverExtension, PerfLogFeatures} from '../web_driver_extension';
+import {Metric} from '../metric';
+import {Options} from '../common_options';
/**
* A metric that reads out the performance log
*/
export class PerflogMetric extends Metric {
// TODO(tbosch): use static values when our transpiler supports them
- static get BINDINGS() { return _BINDINGS; }
+ static get BINDINGS(): List { return _BINDINGS; }
// TODO(tbosch): use static values when our transpiler supports them
- static get SET_TIMEOUT() { return _SET_TIMEOUT; }
+ static get SET_TIMEOUT(): OpaqueToken { return _SET_TIMEOUT; }
+
+ private _remainingEvents: List>;
+ private _measureCount: int;
+ _perfLogFeatures: PerfLogFeatures;
- _driverExtension:WebDriverExtension;
- _remainingEvents:List;
- _measureCount:int;
- _setTimeout:Function;
- _microMetrics:StringMap;
- _perfLogFeatures:PerfLogFeatures;
- _forceGc:boolean;
/**
* @param driverExtension
* @param setTimeout
* @param microMetrics Name and description of metrics provided via console.time / console.timeEnd
**/
- constructor(driverExtension:WebDriverExtension, setTimeout:Function, microMetrics:StringMap, forceGc) {
+ constructor(private _driverExtension: WebDriverExtension, private _setTimeout: Function,
+ private _microMetrics: StringMap, private _forceGc: boolean) {
super();
- this._driverExtension = driverExtension;
+
this._remainingEvents = [];
this._measureCount = 0;
- this._setTimeout = setTimeout;
- this._microMetrics = microMetrics;
- this._perfLogFeatures = driverExtension.perfLogFeatures();
- this._forceGc = forceGc;
+ this._perfLogFeatures = _driverExtension.perfLogFeatures();
}
- describe():StringMap {
+ describe(): StringMap {
var res = {
'scriptTime': 'script execution time in ms, including gc and render',
'pureScriptTime': 'script execution time in ms, without gc nor render'
@@ -59,21 +60,20 @@ export class PerflogMetric extends Metric {
res['forcedGcAmount'] = 'forced gc amount in kbytes';
}
}
- StringMapWrapper.forEach(this._microMetrics, (desc, name) => {
- StringMapWrapper.set(res, name, desc);
- });
+ StringMapWrapper.forEach(this._microMetrics,
+ (desc, name) => { StringMapWrapper.set(res, name, desc); });
return res;
}
- beginMeasure():Promise {
+ beginMeasure(): Promise {
var resultPromise = PromiseWrapper.resolve(null);
if (this._forceGc) {
- resultPromise = resultPromise.then( (_) => this._driverExtension.gc() );
+ resultPromise = resultPromise.then((_) => this._driverExtension.gc());
}
- return resultPromise.then( (_) => this._beginMeasure() );
+ return resultPromise.then((_) => this._beginMeasure());
}
- endMeasure(restart:boolean):Promise {
+ endMeasure(restart: boolean): Promise> {
if (this._forceGc) {
return this._endPlainMeasureAndMeasureForceGc(restart);
} else {
@@ -81,47 +81,43 @@ export class PerflogMetric extends Metric {
}
}
- _endPlainMeasureAndMeasureForceGc(restartMeasure:boolean) {
- return this._endMeasure(true).then( (measurValues) => {
- return this._driverExtension.gc()
- .then( (_) => this._endMeasure(restartMeasure) )
- .then( (forceGcMeasureValues) => {
- StringMapWrapper.set(measurValues, 'forcedGcTime', forceGcMeasureValues['gcTime']);
- StringMapWrapper.set(measurValues, 'forcedGcAmount', forceGcMeasureValues['gcAmount']);
- return measurValues;
+ _endPlainMeasureAndMeasureForceGc(restartMeasure: boolean) {
+ return this._endMeasure(true).then((measureValues) => {
+ return this._driverExtension.gc()
+ .then((_) => this._endMeasure(restartMeasure))
+ .then((forceGcMeasureValues) => {
+ StringMapWrapper.set(measureValues, 'forcedGcTime', forceGcMeasureValues['gcTime']);
+ StringMapWrapper.set(measureValues, 'forcedGcAmount', forceGcMeasureValues['gcAmount']);
+ return measureValues;
});
- });
+ });
}
- _beginMeasure():Promise {
+ _beginMeasure(): Promise {
return this._driverExtension.timeBegin(this._markName(this._measureCount++));
}
- _endMeasure(restart:boolean):Promise {
- var markName = this._markName(this._measureCount-1);
+ _endMeasure(restart: boolean): Promise> {
+ var markName = this._markName(this._measureCount - 1);
var nextMarkName = restart ? this._markName(this._measureCount++) : null;
return this._driverExtension.timeEnd(markName, nextMarkName)
- .then( (_) => this._readUntilEndMark(markName) );
+ .then((_) => this._readUntilEndMark(markName));
}
- _readUntilEndMark(markName:string, loopCount:int = 0, startEvent = null) {
+ _readUntilEndMark(markName: string, loopCount: int = 0, startEvent = null) {
if (loopCount > _MAX_RETRY_COUNT) {
throw new BaseException(`Tried too often to get the ending mark: ${loopCount}`);
}
- return this._driverExtension.readPerfLog().then( (events) => {
+ return this._driverExtension.readPerfLog().then((events) => {
this._addEvents(events);
- var result = this._aggregateEvents(
- this._remainingEvents, markName
- );
+ var result = this._aggregateEvents(this._remainingEvents, markName);
if (isPresent(result)) {
this._remainingEvents = events;
return result;
}
var completer = PromiseWrapper.completer();
- this._setTimeout(
- () => completer.resolve(this._readUntilEndMark(markName, loopCount+1)),
- 100
- );
+ this._setTimeout(() => completer.resolve(this._readUntilEndMark(markName, loopCount + 1)),
+ 100);
return completer.promise;
});
}
@@ -148,22 +144,15 @@ export class PerflogMetric extends Metric {
});
if (needSort) {
// Need to sort because of the ph==='X' events
- ListWrapper.sort(this._remainingEvents, (a,b) => {
+ ListWrapper.sort(this._remainingEvents, (a, b) => {
var diff = a['ts'] - b['ts'];
- return diff > 0
- ? 1
- : diff < 0
- ? -1
- : 0;
+ return diff > 0 ? 1 : diff < 0 ? -1 : 0;
});
}
}
- _aggregateEvents(events, markName) {
- var result = {
- 'scriptTime': 0,
- 'pureScriptTime': 0
- };
+ _aggregateEvents(events, markName): StringMap {
+ var result = {'scriptTime': 0, 'pureScriptTime': 0};
if (this._perfLogFeatures.gc) {
result['gcTime'] = 0;
result['majorGcTime'] = 0;
@@ -172,9 +161,7 @@ export class PerflogMetric extends Metric {
if (this._perfLogFeatures.render) {
result['renderTime'] = 0;
}
- StringMapWrapper.forEach(this._microMetrics, (desc, name) => {
- result[name] = 0;
- });
+ StringMapWrapper.forEach(this._microMetrics, (desc, name) => { result[name] = 0; });
var markStartEvent = null;
var markEndEvent = null;
@@ -182,7 +169,7 @@ export class PerflogMetric extends Metric {
var renderTimeInScript = 0;
var intervalStarts = {};
- events.forEach( (event) => {
+ events.forEach((event) => {
var ph = event['ph'];
var name = event['name'];
var microIterations = 1;
@@ -197,16 +184,19 @@ export class PerflogMetric extends Metric {
} else if (StringWrapper.equals(ph, 'e') && StringWrapper.equals(name, markName)) {
markEndEvent = event;
}
- if (isPresent(markStartEvent) && isBlank(markEndEvent) && event['pid'] === markStartEvent['pid']) {
+ if (isPresent(markStartEvent) && isBlank(markEndEvent) &&
+ event['pid'] === markStartEvent['pid']) {
if (StringWrapper.equals(ph, 'B') || StringWrapper.equals(ph, 'b')) {
intervalStarts[name] = event;
- } else if ((StringWrapper.equals(ph, 'E') || StringWrapper.equals(ph, 'e')) && isPresent(intervalStarts[name])) {
+ } else if ((StringWrapper.equals(ph, 'E') || StringWrapper.equals(ph, 'e')) &&
+ isPresent(intervalStarts[name])) {
var startEvent = intervalStarts[name];
var duration = (event['ts'] - startEvent['ts']);
intervalStarts[name] = null;
if (StringWrapper.equals(name, 'gc')) {
result['gcTime'] += duration;
- var amount = (startEvent['args']['usedHeapSize'] - event['args']['usedHeapSize']) / 1000;
+ var amount =
+ (startEvent['args']['usedHeapSize'] - event['args']['usedHeapSize']) / 1000;
result['gcAmount'] += amount;
var majorGc = event['args']['majorGc'];
if (isPresent(majorGc) && majorGc) {
@@ -232,21 +222,18 @@ export class PerflogMetric extends Metric {
return isPresent(markStartEvent) && isPresent(markEndEvent) ? result : null;
}
- _markName(index) {
- return `${_MARK_NAME_PREFIX}${index}`;
- }
+ _markName(index) { return `${_MARK_NAME_PREFIX}${index}`; }
}
-
var _MICRO_ITERATIONS_REGEX = RegExpWrapper.create('(.+)\\*(\\d+)$');
var _MAX_RETRY_COUNT = 20;
var _MARK_NAME_PREFIX = 'benchpress';
var _SET_TIMEOUT = new OpaqueToken('PerflogMetric.setTimeout');
+
var _BINDINGS = [
- bind(PerflogMetric).toFactory(
- (driverExtension, setTimeout, microMetrics, forceGc) =>
- new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc),
- [WebDriverExtension, _SET_TIMEOUT, Options.MICRO_METRICS, Options.FORCE_GC]
- ),
- bind(_SET_TIMEOUT).toValue( (fn, millis) => TimerWrapper.setTimeout(fn, millis) )
+ bind(PerflogMetric)
+ .toFactory((driverExtension, setTimeout, microMetrics, forceGc) =>
+ new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc),
+ [WebDriverExtension, _SET_TIMEOUT, Options.MICRO_METRICS, Options.FORCE_GC]),
+ bind(_SET_TIMEOUT).toValue((fn, millis) => TimerWrapper.setTimeout(fn, millis))
];
diff --git a/modules/benchpress/src/reporter.js b/modules/benchpress/src/reporter.js
deleted file mode 100644
index ddeae7b139..0000000000
--- a/modules/benchpress/src/reporter.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import { bind } from 'angular2/di';
-import {
- Promise, PromiseWrapper
-} from 'angular2/src/facade/async';
-import {
- ABSTRACT, BaseException
-} from 'angular2/src/facade/lang';
-
-import { MeasureValues } from './measure_values';
-
-/**
- * A reporter reports measure values and the valid sample.
- */
-@ABSTRACT()
-export class Reporter {
- static bindTo(delegateToken) {
- return [
- bind(Reporter).toFactory(
- (delegate) => delegate, [delegateToken]
- )
- ];
- }
-
- reportMeasureValues(values:MeasureValues):Promise {
- throw new BaseException('NYI');
- }
-
- reportSample(completeSample:List, validSample:List):Promise {
- throw new BaseException('NYI');
- }
-}
diff --git a/modules/benchpress/src/reporter.ts b/modules/benchpress/src/reporter.ts
new file mode 100644
index 0000000000..ccd31ebdcf
--- /dev/null
+++ b/modules/benchpress/src/reporter.ts
@@ -0,0 +1,22 @@
+import {bind} from 'angular2/di';
+import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
+import {ABSTRACT, BaseException} from 'angular2/src/facade/lang';
+import {MeasureValues} from './measure_values';
+import {List} from 'angular2/src/facade/collection';
+
+/**
+ * A reporter reports measure values and the valid sample.
+ */
+@ABSTRACT()
+export class Reporter {
+ static bindTo(delegateToken) {
+ return [bind(Reporter).toFactory((delegate) => delegate, [delegateToken])];
+ }
+
+ reportMeasureValues(values: MeasureValues): Promise { throw new BaseException('NYI'); }
+
+ reportSample(completeSample: List,
+ validSample: List): Promise {
+ throw new BaseException('NYI');
+ }
+}
diff --git a/modules/benchpress/src/reporter/console_reporter.js b/modules/benchpress/src/reporter/console_reporter.js
deleted file mode 100644
index 3663075eb0..0000000000
--- a/modules/benchpress/src/reporter/console_reporter.js
+++ /dev/null
@@ -1,115 +0,0 @@
-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';
-import { bind, OpaqueToken } from 'angular2/di';
-
-import { Statistic } from '../statistic';
-import { Reporter } from '../reporter';
-import { SampleDescription } from '../sample_description';
-import { MeasureValues } from '../measure_values';
-
-/**
- * A reporter for the console
- */
-export class ConsoleReporter extends Reporter {
- // TODO(tbosch): use static values when our transpiler supports them
- static get PRINT() { return _PRINT; }
- // TODO(tbosch): use static values when our transpiler supports them
- static get COLUMN_WIDTH() { return _COLUMN_WIDTH; }
- // TODO(tbosch): use static values when our transpiler supports them
- static get BINDINGS() { return _BINDINGS; }
-
- static _lpad(value, columnWidth, fill = ' ') {
- var result = '';
- for (var i=0; i ListWrapper.push(props, prop));
- props.sort();
- return props;
- }
-
- _columnWidth:number;
- _metricNames:List;
- _print:Function;
-
- constructor(columnWidth, sampleDescription, print) {
- super();
- this._columnWidth = columnWidth;
- this._metricNames = ConsoleReporter._sortedProps(sampleDescription.metrics);
- this._print = print;
- this._printDescription(sampleDescription);
- }
-
- _printDescription(sampleDescription) {
- this._print(`BENCHMARK ${sampleDescription.id}`);
- this._print('Description:');
- var props = ConsoleReporter._sortedProps(sampleDescription.description);
- props.forEach( (prop) => {
- this._print(`- ${prop}: ${sampleDescription.description[prop]}`);
- });
- this._print('Metrics:');
- this._metricNames.forEach( (metricName) => {
- this._print(`- ${metricName}: ${sampleDescription.metrics[metricName]}`);
- });
- this._print('');
- this._printStringRow(this._metricNames);
- this._printStringRow(this._metricNames.map( (_) => '' ), '-');
- }
-
- reportMeasureValues(measureValues:MeasureValues):Promise {
- var formattedValues = ListWrapper.map(this._metricNames, (metricName) => {
- var value = measureValues.values[metricName];
- return ConsoleReporter._formatNum(value);
- });
- this._printStringRow(formattedValues);
- return PromiseWrapper.resolve(null);
- }
-
- reportSample(completeSample:List, validSample:List):Promise {
- this._printStringRow(this._metricNames.map( (_) => '' ), '=');
- this._printStringRow(
- ListWrapper.map(this._metricNames, (metricName) => {
- var sample = ListWrapper.map(validSample, (measureValues) => measureValues.values[metricName]);
- var mean = Statistic.calculateMean(sample);
- var cv = Statistic.calculateCoefficientOfVariation(sample, mean);
- var formattedMean = ConsoleReporter._formatNum(mean)
- // Note: Don't use the unicode character for +- as it might cause
- // hickups for consoles...
- return NumberWrapper.isNaN(cv) ? formattedMean : `${formattedMean}+-${Math.floor(cv)}%`;
- })
- );
- return PromiseWrapper.resolve(null);
- }
-
- _printStringRow(parts, fill = ' ') {
- this._print(
- ListWrapper.map(parts, (part) => {
- var w = this._columnWidth;
- return ConsoleReporter._lpad(part, w, fill);
- }).join(' | ')
- );
- }
-
-}
-
-var _PRINT = new OpaqueToken('ConsoleReporter.print');
-var _COLUMN_WIDTH = new OpaqueToken('ConsoleReporter.columnWidht');
-var _BINDINGS = [
- bind(ConsoleReporter).toFactory(
- (columnWidth, sampleDescription, print) => new ConsoleReporter(columnWidth, sampleDescription, print),
- [_COLUMN_WIDTH, SampleDescription, _PRINT]
- ),
- bind(_COLUMN_WIDTH).toValue(18),
- bind(_PRINT).toValue(print)
-];
diff --git a/modules/benchpress/src/reporter/console_reporter.ts b/modules/benchpress/src/reporter/console_reporter.ts
new file mode 100644
index 0000000000..323bd7eb3d
--- /dev/null
+++ b/modules/benchpress/src/reporter/console_reporter.ts
@@ -0,0 +1,107 @@
+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';
+import {bind, Binding, OpaqueToken} from 'angular2/di';
+
+import {Statistic} from '../statistic';
+import {Reporter} from '../reporter';
+import {SampleDescription} from '../sample_description';
+import {MeasureValues} from '../measure_values';
+
+/**
+ * A reporter for the console
+ */
+export class ConsoleReporter extends Reporter {
+ // TODO(tbosch): use static values when our transpiler supports them
+ static get PRINT(): OpaqueToken { return _PRINT; }
+ // TODO(tbosch): use static values when our transpiler supports them
+ static get COLUMN_WIDTH(): OpaqueToken { return _COLUMN_WIDTH; }
+ // TODO(tbosch): use static values when our transpiler supports them
+ static get BINDINGS(): List { return _BINDINGS; }
+
+
+ static _lpad(value, columnWidth, fill = ' ') {
+ var result = '';
+ for (var i = 0; i < columnWidth - value.length; i++) {
+ result += fill;
+ }
+ return result + value;
+ }
+
+ static _formatNum(n) { return NumberWrapper.toFixed(n, 2); }
+
+ static _sortedProps(obj) {
+ var props = [];
+ StringMapWrapper.forEach(obj, (value, prop) => ListWrapper.push(props, prop));
+ props.sort();
+ return props;
+ }
+
+ private _metricNames: List;
+
+ constructor(private _columnWidth: number, sampleDescription, private _print: Function) {
+ super();
+ this._metricNames = ConsoleReporter._sortedProps(sampleDescription.metrics);
+ this._printDescription(sampleDescription);
+ }
+
+ _printDescription(sampleDescription) {
+ this._print(`BENCHMARK ${sampleDescription.id}`);
+ this._print('Description:');
+ var props = ConsoleReporter._sortedProps(sampleDescription.description);
+ props.forEach((prop) => { this._print(`- ${prop}: ${sampleDescription.description[prop]}`); });
+ this._print('Metrics:');
+ this._metricNames.forEach((metricName) => {
+ this._print(`- ${metricName}: ${sampleDescription.metrics[metricName]}`);
+ });
+ this._print('');
+ this._printStringRow(this._metricNames);
+ this._printStringRow(this._metricNames.map((_) => ''), '-');
+ }
+
+ reportMeasureValues(measureValues: MeasureValues): Promise {
+ var formattedValues = ListWrapper.map(this._metricNames, (metricName) => {
+ var value = measureValues.values[metricName];
+ return ConsoleReporter._formatNum(value);
+ });
+ this._printStringRow(formattedValues);
+ return PromiseWrapper.resolve(null);
+ }
+
+ reportSample(completeSample: List,
+ validSample: List): Promise {
+ this._printStringRow(this._metricNames.map((_) => ''), '=');
+ this._printStringRow(ListWrapper.map(this._metricNames, (metricName) => {
+ var sample =
+ ListWrapper.map(validSample, (measureValues) => measureValues.values[metricName]);
+ var mean = Statistic.calculateMean(sample);
+ var cv = Statistic.calculateCoefficientOfVariation(sample, mean);
+ var formattedMean = ConsoleReporter._formatNum(mean)
+ // Note: Don't use the unicode character for +- as it might cause
+ // hickups for consoles...
+ return NumberWrapper.isNaN(cv) ?
+ formattedMean :
+ `${formattedMean}+-${Math.floor(cv)}%`;
+ }));
+ return PromiseWrapper.resolve(null);
+ }
+
+ _printStringRow(parts, fill = ' ') {
+ this._print(ListWrapper.map(parts, (part) => {
+ var w = this._columnWidth;
+ return ConsoleReporter._lpad(part, w, fill);
+ }).join(' | '));
+ }
+}
+
+var _PRINT = new OpaqueToken('ConsoleReporter.print');
+var _COLUMN_WIDTH = new OpaqueToken('ConsoleReporter.columnWidth');
+var _BINDINGS = [
+ bind(ConsoleReporter)
+ .toFactory((columnWidth, sampleDescription, print) =>
+ new ConsoleReporter(columnWidth, sampleDescription, print),
+ [_COLUMN_WIDTH, SampleDescription, _PRINT]),
+ bind(_COLUMN_WIDTH).toValue(18),
+ bind(_PRINT).toValue(print)
+];
diff --git a/modules/benchpress/src/reporter/json_file_reporter.js b/modules/benchpress/src/reporter/json_file_reporter.js
deleted file mode 100644
index d1ccf50bb1..0000000000
--- a/modules/benchpress/src/reporter/json_file_reporter.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import { DateWrapper, isPresent, isBlank, Json } from 'angular2/src/facade/lang';
-import { List } from 'angular2/src/facade/collection';
-import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
-
-import { bind, OpaqueToken } from 'angular2/di';
-
-import { Reporter } from '../reporter';
-import { SampleDescription } from '../sample_description';
-import { MeasureValues } from '../measure_values';
-import { Options } from '../common_options';
-
-/**
- * A reporter that writes results into a json file.
- */
-export class JsonFileReporter extends Reporter {
- // TODO(tbosch): use static values when our transpiler supports them
- static get PATH() { return _PATH; }
- static get BINDINGS() { return _BINDINGS; }
-
- _writeFile:Function;
- _path:string;
- _description:SampleDescription;
- _now:Function;
-
- constructor(sampleDescription, path, writeFile, now) {
- super();
- this._description = sampleDescription;
- this._path = path;
- this._writeFile = writeFile;
- this._now = now;
- }
-
- reportMeasureValues(measureValues:MeasureValues):Promise {
- return PromiseWrapper.resolve(null);
- }
-
- reportSample(completeSample:List, validSample:List):Promise {
- var content = Json.stringify({
- 'description': this._description,
- 'completeSample': completeSample,
- 'validSample': validSample
- });
- var filePath = `${this._path}/${this._description.id}_${DateWrapper.toMillis(this._now())}.json`;
- return this._writeFile(filePath, content);
- }
-}
-
-var _PATH = new OpaqueToken('JsonFileReporter.path');
-var _BINDINGS = [
- bind(JsonFileReporter).toFactory(
- (sampleDescription, path, writeFile, now) => new JsonFileReporter(sampleDescription, path, writeFile, now),
- [SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]
- ),
- bind(_PATH).toValue('.')
-];
diff --git a/modules/benchpress/src/reporter/json_file_reporter.ts b/modules/benchpress/src/reporter/json_file_reporter.ts
new file mode 100644
index 0000000000..ae704c1b90
--- /dev/null
+++ b/modules/benchpress/src/reporter/json_file_reporter.ts
@@ -0,0 +1,58 @@
+import {DateWrapper, isPresent, isBlank, Json} from 'angular2/src/facade/lang';
+import {List} from 'angular2/src/facade/collection';
+import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
+
+import {bind, Binding, OpaqueToken} from 'angular2/di';
+
+import {Reporter} from '../reporter';
+import {SampleDescription} from '../sample_description';
+import {MeasureValues} from '../measure_values';
+import {Options} from '../common_options';
+
+/**
+ * A reporter that writes results into a json file.
+ */
+export class JsonFileReporter extends Reporter {
+ // TODO(tbosch): use static values when our transpiler supports them
+ static get PATH(): OpaqueToken { return _PATH; }
+ // TODO(tbosch): use static values when our transpiler supports them
+ static get BINDINGS(): List { return _BINDINGS; }
+
+ _writeFile: Function;
+ _path: string;
+ _description: SampleDescription;
+ _now: Function;
+
+ constructor(sampleDescription, path, writeFile, now) {
+ super();
+ this._description = sampleDescription;
+ this._path = path;
+ this._writeFile = writeFile;
+ this._now = now;
+ }
+
+ reportMeasureValues(measureValues: MeasureValues): Promise {
+ return PromiseWrapper.resolve(null);
+ }
+
+ reportSample(completeSample: List,
+ validSample: List): Promise {
+ var content = Json.stringify({
+ 'description': this._description,
+ 'completeSample': completeSample,
+ 'validSample': validSample
+ });
+ var filePath =
+ `${this._path}/${this._description.id}_${DateWrapper.toMillis(this._now())}.json`;
+ return this._writeFile(filePath, content);
+ }
+}
+
+var _PATH = new OpaqueToken('JsonFileReporter.path');
+var _BINDINGS = [
+ bind(JsonFileReporter)
+ .toFactory((sampleDescription, path, writeFile, now) =>
+ new JsonFileReporter(sampleDescription, path, writeFile, now),
+ [SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
+ bind(_PATH).toValue('.')
+];
diff --git a/modules/benchpress/src/reporter/multi_reporter.js b/modules/benchpress/src/reporter/multi_reporter.js
deleted file mode 100644
index 239dbc631c..0000000000
--- a/modules/benchpress/src/reporter/multi_reporter.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import { bind, Injector, OpaqueToken } from 'angular2/di';
-import { List, ListWrapper } from 'angular2/src/facade/collection';
-import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
-
-import { MeasureValues } from '../measure_values';
-import { Reporter } from '../reporter';
-
-export class MultiReporter extends Reporter {
- static createBindings(childTokens) {
- return [
- bind(_CHILDREN).toAsyncFactory(
- (injector) => PromiseWrapper.all(ListWrapper.map(childTokens, (token) => injector.asyncGet(token) )),
- [Injector]
- ),
- bind(MultiReporter).toFactory(
- (children) => new MultiReporter(children),
- [_CHILDREN]
- )
- ];
- }
-
- _reporters:List;
-
- constructor(reporters) {
- super();
- this._reporters = reporters;
- }
-
- reportMeasureValues(values:MeasureValues):Promise {
- return PromiseWrapper.all(ListWrapper.map(
- this._reporters, (reporter) => reporter.reportMeasureValues(values)
- ));
- }
-
- reportSample(completeSample:List, validSample:List):Promise {
- return PromiseWrapper.all(ListWrapper.map(
- this._reporters, (reporter) => reporter.reportSample(completeSample, validSample)
- ));
- }
-}
-
-var _CHILDREN = new OpaqueToken('MultiReporter.children');
diff --git a/modules/benchpress/src/reporter/multi_reporter.ts b/modules/benchpress/src/reporter/multi_reporter.ts
new file mode 100644
index 0000000000..62fe2c302c
--- /dev/null
+++ b/modules/benchpress/src/reporter/multi_reporter.ts
@@ -0,0 +1,38 @@
+import {bind, Binding, Injector, OpaqueToken} from 'angular2/di';
+import {List, ListWrapper} from 'angular2/src/facade/collection';
+import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
+
+import {MeasureValues} from '../measure_values';
+import {Reporter} from '../reporter';
+
+export class MultiReporter extends Reporter {
+ static createBindings(childTokens: List): List {
+ return [
+ bind(_CHILDREN)
+ .toAsyncFactory((injector) => PromiseWrapper.all(
+ ListWrapper.map(childTokens, (token) => injector.asyncGet(token))),
+ [Injector]),
+ bind(MultiReporter).toFactory((children) => new MultiReporter(children), [_CHILDREN])
+ ];
+ }
+
+ _reporters: List;
+
+ constructor(reporters) {
+ super();
+ this._reporters = reporters;
+ }
+
+ reportMeasureValues(values: MeasureValues): Promise> {
+ return PromiseWrapper.all(
+ ListWrapper.map(this._reporters, (reporter) => reporter.reportMeasureValues(values)));
+ }
+
+ reportSample(completeSample: List,
+ validSample: List): Promise> {
+ return PromiseWrapper.all(ListWrapper.map(
+ this._reporters, (reporter) => reporter.reportSample(completeSample, validSample)));
+ }
+}
+
+var _CHILDREN = new OpaqueToken('MultiReporter.children');
diff --git a/modules/benchpress/src/runner.js b/modules/benchpress/src/runner.js
deleted file mode 100644
index e1eac007d2..0000000000
--- a/modules/benchpress/src/runner.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import { Injector, bind } from 'angular2/di';
-import { isPresent, isBlank } from 'angular2/src/facade/lang';
-import { List, ListWrapper } from 'angular2/src/facade/collection';
-import { Promise } from 'angular2/src/facade/async';
-
-import { Sampler, SampleState } from './sampler';
-import { ConsoleReporter } from './reporter/console_reporter';
-import { MultiReporter } from './reporter/multi_reporter';
-import { RegressionSlopeValidator } from './validator/regression_slope_validator';
-import { SizeValidator } from './validator/size_validator';
-import { Validator } from './validator';
-import { PerflogMetric } from './metric/perflog_metric';
-import { MultiMetric } from './metric/multi_metric';
-import { ChromeDriverExtension } from './webdriver/chrome_driver_extension';
-import { IOsDriverExtension } from './webdriver/ios_driver_extension';
-import { WebDriverExtension } from './web_driver_extension';
-import { SampleDescription } from './sample_description';
-import { WebDriverAdapter } from './web_driver_adapter';
-import { Reporter } from './reporter';
-import { Metric } from './metric';
-import { Options } from './common_options';
-
-/**
- * The Runner is the main entry point for executing a sample run.
- * It provides defaults, creates the injector and calls the sampler.
- */
-export class Runner {
- _defaultBindings:List;
-
- constructor(defaultBindings:List = null) {
- if (isBlank(defaultBindings)) {
- defaultBindings = [];
- }
- this._defaultBindings = defaultBindings;
- }
-
- sample({id, execute, prepare, microMetrics, bindings}):Promise {
- var sampleBindings = [
- _DEFAULT_BINDINGS,
- this._defaultBindings,
- bind(Options.SAMPLE_ID).toValue(id),
- bind(Options.EXECUTE).toValue(execute)
- ];
- if (isPresent(prepare)) {
- ListWrapper.push(sampleBindings, bind(Options.PREPARE).toValue(prepare));
- }
- if (isPresent(microMetrics)) {
- ListWrapper.push(sampleBindings, bind(Options.MICRO_METRICS).toValue(microMetrics));
- }
- if (isPresent(bindings)) {
- ListWrapper.push(sampleBindings, bindings);
- }
- return Injector.resolveAndCreate(sampleBindings).asyncGet(Sampler)
- .then( (sampler) => sampler.sample() );
- }
-}
-
-var _DEFAULT_BINDINGS = [
- Options.DEFAULT_BINDINGS,
- Sampler.BINDINGS,
- ConsoleReporter.BINDINGS,
- RegressionSlopeValidator.BINDINGS,
- SizeValidator.BINDINGS,
- ChromeDriverExtension.BINDINGS,
- IOsDriverExtension.BINDINGS,
- PerflogMetric.BINDINGS,
- SampleDescription.BINDINGS,
- MultiReporter.createBindings([ConsoleReporter]),
- MultiMetric.createBindings([PerflogMetric]),
-
- Reporter.bindTo(MultiReporter),
- Validator.bindTo(RegressionSlopeValidator),
- WebDriverExtension.bindTo([ChromeDriverExtension, IOsDriverExtension]),
- Metric.bindTo(MultiMetric),
-
- bind(Options.CAPABILITIES).toAsyncFactory(
- (adapter) => adapter.capabilities(), [WebDriverAdapter]
- ),
- bind(Options.USER_AGENT).toAsyncFactory(
- (adapter) => adapter.executeScript('return window.navigator.userAgent;'), [WebDriverAdapter]
- )
-];
diff --git a/modules/benchpress/src/runner.ts b/modules/benchpress/src/runner.ts
new file mode 100644
index 0000000000..0a5cb08f07
--- /dev/null
+++ b/modules/benchpress/src/runner.ts
@@ -0,0 +1,81 @@
+import {Injector, bind, Binding} from 'angular2/di';
+import {isPresent, isBlank} from 'angular2/src/facade/lang';
+import {List, ListWrapper} from 'angular2/src/facade/collection';
+import {Promise} from 'angular2/src/facade/async';
+
+import {Sampler, SampleState} from './sampler';
+import {ConsoleReporter} from './reporter/console_reporter';
+import {MultiReporter} from './reporter/multi_reporter';
+import {RegressionSlopeValidator} from './validator/regression_slope_validator';
+import {SizeValidator} from './validator/size_validator';
+import {Validator} from './validator';
+import {PerflogMetric} from './metric/perflog_metric';
+import {MultiMetric} from './metric/multi_metric';
+import {ChromeDriverExtension} from './webdriver/chrome_driver_extension';
+import {IOsDriverExtension} from './webdriver/ios_driver_extension';
+import {WebDriverExtension} from './web_driver_extension';
+import {SampleDescription} from './sample_description';
+import {WebDriverAdapter} from './web_driver_adapter';
+import {Reporter} from './reporter';
+import {Metric} from './metric';
+import {Options} from './common_options';
+
+/**
+ * The Runner is the main entry point for executing a sample run.
+ * It provides defaults, creates the injector and calls the sampler.
+ */
+export class Runner {
+ private _defaultBindings: List;
+ constructor(defaultBindings: List = null) {
+ if (isBlank(defaultBindings)) {
+ defaultBindings = [];
+ }
+ this._defaultBindings = defaultBindings;
+ }
+
+ sample({id, execute, prepare, microMetrics, bindings}): Promise {
+ var sampleBindings = [
+ _DEFAULT_BINDINGS,
+ this._defaultBindings,
+ bind(Options.SAMPLE_ID).toValue(id),
+ bind(Options.EXECUTE).toValue(execute)
+ ];
+ if (isPresent(prepare)) {
+ ListWrapper.push(sampleBindings, bind(Options.PREPARE).toValue(prepare));
+ }
+ if (isPresent(microMetrics)) {
+ ListWrapper.push(sampleBindings, bind(Options.MICRO_METRICS).toValue(microMetrics));
+ }
+ if (isPresent(bindings)) {
+ ListWrapper.push(sampleBindings, bindings);
+ }
+ return Injector.resolveAndCreate(sampleBindings)
+ .asyncGet(Sampler)
+ .then((sampler) => sampler.sample());
+ }
+}
+
+var _DEFAULT_BINDINGS = [
+ Options.DEFAULT_BINDINGS,
+ Sampler.BINDINGS,
+ ConsoleReporter.BINDINGS,
+ RegressionSlopeValidator.BINDINGS,
+ SizeValidator.BINDINGS,
+ ChromeDriverExtension.BINDINGS,
+ IOsDriverExtension.BINDINGS,
+ PerflogMetric.BINDINGS,
+ SampleDescription.BINDINGS,
+ MultiReporter.createBindings([ConsoleReporter]),
+ MultiMetric.createBindings([PerflogMetric]),
+
+ Reporter.bindTo(MultiReporter),
+ Validator.bindTo(RegressionSlopeValidator),
+ WebDriverExtension.bindTo([ChromeDriverExtension, IOsDriverExtension]),
+ Metric.bindTo(MultiMetric),
+
+ bind(Options.CAPABILITIES)
+ .toAsyncFactory((adapter) => adapter.capabilities(), [WebDriverAdapter]),
+ bind(Options.USER_AGENT)
+ .toAsyncFactory((adapter) => adapter.executeScript('return window.navigator.userAgent;'),
+ [WebDriverAdapter])
+];
diff --git a/modules/benchpress/src/sample_description.js b/modules/benchpress/src/sample_description.js
deleted file mode 100644
index 56949d36ce..0000000000
--- a/modules/benchpress/src/sample_description.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import { StringMapWrapper, ListWrapper, StringMap } from 'angular2/src/facade/collection';
-import { bind, OpaqueToken } from 'angular2/di';
-import { Validator } from './validator';
-import { Metric } from './metric';
-import { Options } from './common_options';
-
-/**
- * SampleDescription merges all available descriptions about a sample
- */
-export class SampleDescription {
- // TODO(tbosch): use static values when our transpiler supports them
- static get BINDINGS() { return _BINDINGS; }
-
- id:string;
- description:StringMap;
- metrics:StringMap;
-
- constructor(id, descriptions:List, metrics:StringMap) {
- this.id = id;
- this.metrics = metrics;
- this.description = {};
- ListWrapper.forEach(descriptions, (description) => {
- StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value );
- });
- }
-
- toJson() {
- return {
- 'id': this.id,
- 'description': this.description,
- 'metrics': this.metrics
- };
- }
-}
-
-var _BINDINGS = [
- bind(SampleDescription).toFactory(
- (metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) => new SampleDescription(id,
- [
- {'forceGc': forceGc, 'userAgent': userAgent},
- validator.describe(),
- defaultDesc,
- userDesc
- ],
- metric.describe()),
- [
- Metric, Options.SAMPLE_ID, Options.FORCE_GC, Options.USER_AGENT,
- Validator, Options.DEFAULT_DESCRIPTION, Options.SAMPLE_DESCRIPTION
- ]
- )
-];
diff --git a/modules/benchpress/src/sample_description.ts b/modules/benchpress/src/sample_description.ts
new file mode 100644
index 0000000000..72eb33aa14
--- /dev/null
+++ b/modules/benchpress/src/sample_description.ts
@@ -0,0 +1,44 @@
+import {StringMapWrapper, ListWrapper, List, StringMap} from 'angular2/src/facade/collection';
+import {bind, Binding, OpaqueToken} from 'angular2/di';
+import {Validator} from './validator';
+import {Metric} from './metric';
+import {Options} from './common_options';
+
+/**
+ * SampleDescription merges all available descriptions about a sample
+ */
+export class SampleDescription {
+ // TODO(tbosch): use static values when our transpiler supports them
+ static get BINDINGS(): List { return _BINDINGS; }
+ description: StringMap;
+
+ constructor(public id: string, descriptions: List>,
+ public metrics: StringMap) {
+ this.description = {};
+ ListWrapper.forEach(descriptions, (description) => {
+ StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value);
+ });
+ }
+
+ toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
+}
+
+var _BINDINGS =
+ [bind(SampleDescription)
+ .toFactory((metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
+ new SampleDescription(id, [
+ {'forceGc': forceGc, 'userAgent': userAgent},
+ validator.describe(),
+ defaultDesc,
+ userDesc
+ ],
+ metric.describe()),
+ [
+ Metric,
+ Options.SAMPLE_ID,
+ Options.FORCE_GC,
+ Options.USER_AGENT,
+ Validator,
+ Options.DEFAULT_DESCRIPTION,
+ Options.SAMPLE_DESCRIPTION
+ ])];
diff --git a/modules/benchpress/src/sampler.js b/modules/benchpress/src/sampler.js
deleted file mode 100644
index 19fb08bf7d..0000000000
--- a/modules/benchpress/src/sampler.js
+++ /dev/null
@@ -1,123 +0,0 @@
-import { isPresent, isBlank, Date, DateWrapper } from 'angular2/src/facade/lang';
-import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
-import { StringMapWrapper, StringMap, List, ListWrapper } from 'angular2/src/facade/collection';
-import { bind, OpaqueToken } from 'angular2/di';
-
-import { Metric } from './metric';
-import { Validator } from './validator';
-import { Reporter } from './reporter';
-import { WebDriverAdapter } from './web_driver_adapter';
-
-import { Options } from './common_options';
-import { MeasureValues} from './measure_values';
-
-/**
- * The Sampler owns the sample loop:
- * 1. calls the prepare/execute callbacks,
- * 2. gets data from the metric
- * 3. asks the validator for a valid sample
- * 4. reports the new data to the reporter
- * 5. loop until there is a valid sample
- */
-export class Sampler {
- // TODO(tbosch): use static values when our transpiler supports them
- static get BINDINGS() { return _BINDINGS; }
-
- _driver:WebDriverAdapter;
- _metric:Metric;
- _reporter:Reporter;
- _validator:Validator;
- _prepare:Function;
- _execute:Function;
- _now:Function;
-
- constructor({
- driver, metric, reporter, validator, prepare, execute, now
- }:{
- driver: WebDriverAdapter,
- metric: Metric, reporter: Reporter,
- validator: Validator, prepare: Function, execute: Function, now: Function
- }={}) {
- this._driver = driver;
- this._metric = metric;
- this._reporter = reporter;
- this._validator = validator;
- this._prepare = prepare;
- this._execute = execute;
- this._now = now;
- }
-
- sample():Promise {
- var loop;
- loop = (lastState) => {
- return this._iterate(lastState)
- .then( (newState) => {
- if (isPresent(newState.validSample)) {
- return newState;
- } else {
- return loop(newState);
- }
- });
- }
- return loop(new SampleState([], null));
- }
-
- _iterate(lastState) {
- var resultPromise;
- if (isPresent(this._prepare)) {
- resultPromise = this._driver.waitFor(this._prepare);
- } else {
- resultPromise = PromiseWrapper.resolve(null);
- }
- if (isPresent(this._prepare) || lastState.completeSample.length === 0) {
- resultPromise = resultPromise.then( (_) => this._metric.beginMeasure() );
- }
- return resultPromise
- .then( (_) => this._driver.waitFor(this._execute) )
- .then( (_) => this._metric.endMeasure(isBlank(this._prepare)) )
- .then( (measureValues) => this._report(lastState, measureValues) );
- }
-
- _report(state:SampleState, metricValues:StringMap):Promise {
- var measureValues = new MeasureValues(state.completeSample.length, this._now(), metricValues);
- var completeSample = ListWrapper.concat(state.completeSample, [measureValues]);
- var validSample = this._validator.validate(completeSample);
- var resultPromise = this._reporter.reportMeasureValues(measureValues);
- if (isPresent(validSample)) {
- resultPromise = resultPromise.then( (_) => this._reporter.reportSample(completeSample, validSample) )
- }
- return resultPromise.then( (_) => new SampleState(completeSample, validSample) );
- }
-
-}
-
-export class SampleState {
- completeSample:List;
- validSample:List;
-
- constructor(completeSample: List, validSample: List) {
- this.completeSample = completeSample;
- this.validSample = validSample;
- }
-}
-
-var _BINDINGS = [
- bind(Sampler).toFactory(
- (driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
- driver: driver,
- reporter: reporter,
- validator: validator,
- metric: metric,
- // TODO(tbosch): DI right now does not support null/undefined objects
- // Mostly because the cache would have to be initialized with a
- // special null object, which is expensive.
- prepare: prepare !== false ? prepare : null,
- execute: execute,
- now: now
- }),
- [
- WebDriverAdapter, Metric, Reporter, Validator,
- Options.PREPARE, Options.EXECUTE, Options.NOW
- ]
- )
-];
diff --git a/modules/benchpress/src/sampler.ts b/modules/benchpress/src/sampler.ts
new file mode 100644
index 0000000000..0b26fb8f30
--- /dev/null
+++ b/modules/benchpress/src/sampler.ts
@@ -0,0 +1,120 @@
+import {isPresent, isBlank, Date, DateWrapper} from 'angular2/src/facade/lang';
+import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
+import {StringMapWrapper, StringMap, List, ListWrapper} from 'angular2/src/facade/collection';
+import {bind, Binding, OpaqueToken} from 'angular2/di';
+
+import {Metric} from './metric';
+import {Validator} from './validator';
+import {Reporter} from './reporter';
+import {WebDriverAdapter} from './web_driver_adapter';
+
+import {Options} from './common_options';
+import {MeasureValues} from './measure_values';
+
+/**
+ * The Sampler owns the sample loop:
+ * 1. calls the prepare/execute callbacks,
+ * 2. gets data from the metric
+ * 3. asks the validator for a valid sample
+ * 4. reports the new data to the reporter
+ * 5. loop until there is a valid sample
+ */
+export class Sampler {
+ // TODO(tbosch): use static values when our transpiler supports them
+ static get BINDINGS(): List { return _BINDINGS; }
+
+ _driver: WebDriverAdapter;
+ _metric: Metric;
+ _reporter: Reporter;
+ _validator: Validator;
+ _prepare: Function;
+ _execute: Function;
+ _now: Function;
+
+ constructor({driver, metric, reporter, validator, prepare, execute, now}: {
+ driver?: WebDriverAdapter,
+ metric?: Metric,
+ reporter?: Reporter,
+ validator?: Validator,
+ prepare?: Function,
+ execute?: Function,
+ now?: Function
+ } = {}) {
+ this._driver = driver;
+ this._metric = metric;
+ this._reporter = reporter;
+ this._validator = validator;
+ this._prepare = prepare;
+ this._execute = execute;
+ this._now = now;
+ }
+
+ sample(): Promise {
+ var loop;
+ loop = (lastState) => {
+ return this._iterate(lastState).then((newState) => {
+ if (isPresent(newState.validSample)) {
+ return newState;
+ } else {
+ return loop(newState);
+ }
+ });
+ };
+ return loop(new SampleState([], null));
+ }
+
+ _iterate(lastState) {
+ var resultPromise;
+ if (isPresent(this._prepare)) {
+ resultPromise = this._driver.waitFor(this._prepare);
+ } else {
+ resultPromise = PromiseWrapper.resolve(null);
+ }
+ if (isPresent(this._prepare) || lastState.completeSample.length === 0) {
+ resultPromise = resultPromise.then((_) => this._metric.beginMeasure());
+ }
+ return resultPromise.then((_) => this._driver.waitFor(this._execute))
+ .then((_) => this._metric.endMeasure(isBlank(this._prepare)))
+ .then((measureValues) => this._report(lastState, measureValues));
+ }
+
+ _report(state: SampleState, metricValues: StringMap): Promise {
+ var measureValues = new MeasureValues(state.completeSample.length, this._now(), metricValues);
+ var completeSample = ListWrapper.concat(state.completeSample, [measureValues]);
+ var validSample = this._validator.validate(completeSample);
+ var resultPromise = this._reporter.reportMeasureValues(measureValues);
+ if (isPresent(validSample)) {
+ resultPromise =
+ resultPromise.then((_) => this._reporter.reportSample(completeSample, validSample))
+ }
+ return resultPromise.then((_) => new SampleState(completeSample, validSample));
+ }
+}
+
+export class SampleState {
+ constructor(public completeSample: List, public validSample: List) {}
+}
+
+var _BINDINGS =
+ [bind(Sampler)
+ .toFactory((driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
+ driver: driver,
+ reporter: reporter,
+ validator: validator,
+ metric: metric,
+ // TODO(tbosch): DI right now does not support null/undefined objects
+ // Mostly because the cache would have to be initialized with a
+ // special null object, which is expensive.
+ prepare: prepare !== false ? prepare : null,
+ execute: execute,
+ now: now
+ }),
+ [
+ WebDriverAdapter,
+ Metric,
+ Reporter,
+ Validator,
+ Options.PREPARE,
+ Options.EXECUTE,
+ Options.NOW
+ ])];
diff --git a/modules/benchpress/src/statistic.js b/modules/benchpress/src/statistic.ts
similarity index 62%
rename from modules/benchpress/src/statistic.js
rename to modules/benchpress/src/statistic.ts
index 61a8d2df88..8fcb86930f 100644
--- a/modules/benchpress/src/statistic.js
+++ b/modules/benchpress/src/statistic.ts
@@ -1,5 +1,5 @@
-import { Math } from 'angular2/src/facade/math';
-import { ListWrapper } from 'angular2/src/facade/collection';
+import {Math} from 'angular2/src/facade/math';
+import {ListWrapper, List} from 'angular2/src/facade/collection';
export class Statistic {
static calculateCoefficientOfVariation(sample, mean) {
@@ -8,30 +8,27 @@ export class Statistic {
static calculateMean(sample) {
var total = 0;
- ListWrapper.forEach(sample, (x) => { total += x } );
+ ListWrapper.forEach(sample, (x) => {total += x});
return total / sample.length;
}
static calculateStandardDeviation(sample, mean) {
var deviation = 0;
- ListWrapper.forEach(sample, (x) => {
- deviation += Math.pow(x - mean, 2);
- });
+ ListWrapper.forEach(sample, (x) => { deviation += Math.pow(x - mean, 2); });
deviation = deviation / (sample.length);
deviation = Math.sqrt(deviation);
return deviation;
}
- static calculateRegressionSlope(xValues, xMean, yValues, yMean) {
+ static calculateRegressionSlope(xValues: List, xMean: number, yValues: List,
+ yMean: number) {
// See http://en.wikipedia.org/wiki/Simple_linear_regression
var dividendSum = 0;
var divisorSum = 0;
- for (var i=0; i delegate, [delegateToken]
- )
- ];
+ return [bind(Validator).toFactory((delegate) => delegate, [delegateToken])];
}
/**
* Calculates a valid sample out of the complete sample
*/
- validate(completeSample:List):List {
+ validate(completeSample: List): List {
throw new BaseException('NYI');
}
@@ -32,7 +26,5 @@ export class Validator {
* Returns a Map that describes the properties of the validator
* (e.g. sample size, ...)
*/
- describe():StringMap {
- throw new BaseException('NYI');
- }
-}
\ No newline at end of file
+ describe(): StringMap { throw new BaseException('NYI'); }
+}
diff --git a/modules/benchpress/src/validator/regression_slope_validator.js b/modules/benchpress/src/validator/regression_slope_validator.ts
similarity index 52%
rename from modules/benchpress/src/validator/regression_slope_validator.js
rename to modules/benchpress/src/validator/regression_slope_validator.ts
index 6960b839d4..435dad34d9 100644
--- a/modules/benchpress/src/validator/regression_slope_validator.js
+++ b/modules/benchpress/src/validator/regression_slope_validator.ts
@@ -1,9 +1,9 @@
-import { List, ListWrapper, StringMap } from 'angular2/src/facade/collection';
-import { bind, OpaqueToken } from 'angular2/di';
+import {List, ListWrapper, StringMap} from 'angular2/src/facade/collection';
+import {bind, Binding, OpaqueToken} from 'angular2/di';
-import { Validator } from '../validator';
-import { Statistic } from '../statistic';
-import { MeasureValues } from '../measure_values';
+import {Validator} from '../validator';
+import {Statistic} from '../statistic';
+import {MeasureValues} from '../measure_values';
/**
* A validator that checks the regression slope of a specific metric.
@@ -11,14 +11,14 @@ import { MeasureValues } from '../measure_values';
*/
export class RegressionSlopeValidator extends Validator {
// TODO(tbosch): use static values when our transpiler supports them
- static get SAMPLE_SIZE() { return _SAMPLE_SIZE; }
+ static get SAMPLE_SIZE(): OpaqueToken { return _SAMPLE_SIZE; }
// TODO(tbosch): use static values when our transpiler supports them
- static get METRIC() { return _METRIC; }
+ static get METRIC(): OpaqueToken { return _METRIC; }
// TODO(tbosch): use static values when our transpiler supports them
- static get BINDINGS() { return _BINDINGS; }
+ static get BINDINGS(): List { return _BINDINGS; }
- _sampleSize:number;
- _metric:string;
+ _sampleSize: number;
+ _metric: string;
constructor(sampleSize, metric) {
super();
@@ -26,44 +26,37 @@ export class RegressionSlopeValidator extends Validator {
this._metric = metric;
}
- describe():StringMap {
- return {
- 'sampleSize': this._sampleSize,
- 'regressionSlopeMetric': this._metric
- };
+ describe(): StringMap {
+ return {'sampleSize': this._sampleSize, 'regressionSlopeMetric': this._metric};
}
- validate(completeSample:List):List {
+ validate(completeSample: List): List {
if (completeSample.length >= this._sampleSize) {
- var latestSample =
- ListWrapper.slice(completeSample, completeSample.length - this._sampleSize, completeSample.length);
+ var latestSample = ListWrapper.slice(completeSample, completeSample.length - this._sampleSize,
+ completeSample.length);
var xValues = [];
var yValues = [];
- for (var i = 0; i= 0 ? latestSample : null;
} else {
return null;
}
}
-
}
var _SAMPLE_SIZE = new OpaqueToken('RegressionSlopeValidator.sampleSize');
var _METRIC = new OpaqueToken('RegressionSlopeValidator.metric');
var _BINDINGS = [
- bind(RegressionSlopeValidator).toFactory(
- (sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
- [_SAMPLE_SIZE, _METRIC]
- ),
+ bind(RegressionSlopeValidator)
+ .toFactory((sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
+ [_SAMPLE_SIZE, _METRIC]),
bind(_SAMPLE_SIZE).toValue(10),
bind(_METRIC).toValue('scriptTime')
];
diff --git a/modules/benchpress/src/validator/size_validator.js b/modules/benchpress/src/validator/size_validator.ts
similarity index 51%
rename from modules/benchpress/src/validator/size_validator.js
rename to modules/benchpress/src/validator/size_validator.ts
index cbc71550b3..3f407f9ad5 100644
--- a/modules/benchpress/src/validator/size_validator.js
+++ b/modules/benchpress/src/validator/size_validator.ts
@@ -1,46 +1,40 @@
-import { List, ListWrapper, StringMap } from 'angular2/src/facade/collection';
-import { bind, OpaqueToken } from 'angular2/di';
+import {List, ListWrapper, StringMap} from 'angular2/src/facade/collection';
+import {bind, Binding, OpaqueToken} from 'angular2/di';
-import { Validator } from '../validator';
-import { MeasureValues } from '../measure_values';
+import {Validator} from '../validator';
+import {MeasureValues} from '../measure_values';
/**
* A validator that waits for the sample to have a certain size.
*/
export class SizeValidator extends Validator {
// TODO(tbosch): use static values when our transpiler supports them
- static get BINDINGS() { return _BINDINGS; }
+ static get BINDINGS(): List { return _BINDINGS; }
// TODO(tbosch): use static values when our transpiler supports them
static get SAMPLE_SIZE() { return _SAMPLE_SIZE; }
- _sampleSize:number;
+ _sampleSize: number;
constructor(size) {
super();
this._sampleSize = size;
}
- describe():StringMap {
- return {
- 'sampleSize': this._sampleSize
- };
- }
+ describe(): StringMap { return {'sampleSize': this._sampleSize}; }
- validate(completeSample:List):List {
+ validate(completeSample: List): List {
if (completeSample.length >= this._sampleSize) {
- return ListWrapper.slice(completeSample, completeSample.length - this._sampleSize, completeSample.length);
+ return ListWrapper.slice(completeSample, completeSample.length - this._sampleSize,
+ completeSample.length);
} else {
return null;
}
}
-
}
var _SAMPLE_SIZE = new OpaqueToken('SizeValidator.sampleSize');
var _BINDINGS = [
- bind(SizeValidator).toFactory(
- (size) => new SizeValidator(size),
- [_SAMPLE_SIZE]
- ),
+ bind(SizeValidator)
+ .toFactory((size) => new SizeValidator(size), [_SAMPLE_SIZE]),
bind(_SAMPLE_SIZE).toValue(10)
-];
\ No newline at end of file
+];
diff --git a/modules/benchpress/src/web_driver_adapter.js b/modules/benchpress/src/web_driver_adapter.js
deleted file mode 100644
index 9e27e06817..0000000000
--- a/modules/benchpress/src/web_driver_adapter.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import { bind } from 'angular2/di';
-import { Promise } from 'angular2/src/facade/async';
-import { BaseException, ABSTRACT } from 'angular2/src/facade/lang';
-import { List, Map } from 'angular2/src/facade/collection';
-
-/**
- * A WebDriverAdapter bridges API differences between different WebDriver clients,
- * e.g. JS vs Dart Async vs Dart Sync webdriver.
- * Needs one implementation for every supported WebDriver client.
- */
-@ABSTRACT()
-export class WebDriverAdapter {
- static bindTo(delegateToken) {
- return [
- bind(WebDriverAdapter).toFactory(
- (delegate) => delegate, [delegateToken]
- )
- ];
- }
-
- waitFor(callback:Function):Promise {
- throw new BaseException('NYI');
- }
- executeScript(script:string):Promise {
- throw new BaseException('NYI');
- }
- capabilities():Promise