Skip to content

Commit fd19671

Browse files
Jason ChoiAlex Rickabaugh
authored andcommitted
chore(benchpress): clang-format and lint
1 parent 3fcd6fd commit fd19671

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1265
-1066
lines changed

gulpfile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const path = require('path');
1111
const os = require('os');
1212

1313
const srcsToFmt =
14-
['tools/**/*.ts', 'modules/@angular/**/*.ts', '!tools/public_api_guard/**/*.d.ts'];
14+
['tools/**/*.ts', 'modules/@angular/**/*.ts', '!tools/public_api_guard/**/*.d.ts',
15+
'modules/benchpress/**/*.ts'];
1516

1617
gulp.task('format:enforce', () => {
1718
const format = require('gulp-clang-format');
@@ -97,7 +98,7 @@ gulp.task('lint', ['format:enforce', 'tools:build'], () => {
9798
// Built-in rules are at
9899
// https://github.com/palantir/tslint#supported-rules
99100
const tslintConfig = require('./tslint.json');
100-
return gulp.src(['modules/@angular/**/*.ts'])
101+
return gulp.src(['modules/@angular/**/*.ts', 'modules/benchpress/**/*.ts'])
101102
.pipe(tslint({
102103
tslint: require('tslint').default,
103104
configuration: tslintConfig,

modules/benchpress/benchpress.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
import {bind} from '@angular/core/src/di';
210
import {Options} from './common';
311

@@ -22,5 +30,5 @@ function writeFile(filename, content): Promise<any> {
2230
resolve();
2331
}
2432
});
25-
})
33+
});
2634
}

modules/benchpress/common.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
export {Sampler, SampleState} from './src/sampler';
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export {Injector, OpaqueToken, ReflectiveInjector, bind, provide} from '@angular/core/src/di';
10+
export {Options} from './src/common_options';
11+
export {MeasureValues} from './src/measure_values';
212
export {Metric} from './src/metric';
3-
export {Validator} from './src/validator';
13+
export {MultiMetric} from './src/metric/multi_metric';
14+
export {PerflogMetric} from './src/metric/perflog_metric';
15+
export {UserMetric} from './src/metric/user_metric';
416
export {Reporter} from './src/reporter';
5-
export {WebDriverExtension, PerfLogFeatures} from './src/web_driver_extension';
6-
export {WebDriverAdapter} from './src/web_driver_adapter';
7-
export {SizeValidator} from './src/validator/size_validator';
8-
export {RegressionSlopeValidator} from './src/validator/regression_slope_validator';
917
export {ConsoleReporter} from './src/reporter/console_reporter';
1018
export {JsonFileReporter} from './src/reporter/json_file_reporter';
19+
export {MultiReporter} from './src/reporter/multi_reporter';
20+
export {Runner} from './src/runner';
1121
export {SampleDescription} from './src/sample_description';
12-
export {PerflogMetric} from './src/metric/perflog_metric';
22+
export {SampleState, Sampler} from './src/sampler';
23+
export {Validator} from './src/validator';
24+
export {RegressionSlopeValidator} from './src/validator/regression_slope_validator';
25+
export {SizeValidator} from './src/validator/size_validator';
26+
export {WebDriverAdapter} from './src/web_driver_adapter';
27+
export {PerfLogFeatures, WebDriverExtension} from './src/web_driver_extension';
1328
export {ChromeDriverExtension} from './src/webdriver/chrome_driver_extension';
1429
export {FirefoxDriverExtension} from './src/webdriver/firefox_driver_extension';
1530
export {IOsDriverExtension} from './src/webdriver/ios_driver_extension';
16-
export {Runner} from './src/runner';
17-
export {Options} from './src/common_options';
18-
export {MeasureValues} from './src/measure_values';
19-
export {MultiMetric} from './src/metric/multi_metric';
20-
export {UserMetric} from './src/metric/user_metric';
21-
export {MultiReporter} from './src/reporter/multi_reporter';
22-
23-
export {bind, provide, Injector, ReflectiveInjector, OpaqueToken} from '@angular/core/src/di';

modules/benchpress/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
require('reflect-metadata');
210
require('es6-shim');
311
module.exports = require('./benchpress.js');

modules/benchpress/src/common_options.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
import {OpaqueToken} from '@angular/core/src/di';
210
import {DateWrapper} from '@angular/facade/src/lang';
311

@@ -52,14 +60,9 @@ var _REQUEST_COUNT = new OpaqueToken('Options.requestCount');
5260
var _CAPTURE_FRAMES = new OpaqueToken('Options.frameCapture');
5361

5462
var _DEFAULT_PROVIDERS = [
55-
{provide: _DEFAULT_DESCRIPTION, useValue: {}},
56-
{provide: _SAMPLE_DESCRIPTION, useValue: {}},
57-
{provide: _FORCE_GC, useValue: false},
58-
{provide: _PREPARE, useValue: false},
59-
{provide: _MICRO_METRICS, useValue: {}},
60-
{provide: _USER_METRICS, useValue: {}},
61-
{provide: _NOW, useValue: () => DateWrapper.now()},
62-
{provide: _RECEIVED_DATA, useValue: false},
63-
{provide: _REQUEST_COUNT, useValue: false},
64-
{provide: _CAPTURE_FRAMES, useValue: false}
63+
{provide: _DEFAULT_DESCRIPTION, useValue: {}}, {provide: _SAMPLE_DESCRIPTION, useValue: {}},
64+
{provide: _FORCE_GC, useValue: false}, {provide: _PREPARE, useValue: false},
65+
{provide: _MICRO_METRICS, useValue: {}}, {provide: _USER_METRICS, useValue: {}},
66+
{provide: _NOW, useValue: () => DateWrapper.now()}, {provide: _RECEIVED_DATA, useValue: false},
67+
{provide: _REQUEST_COUNT, useValue: false}, {provide: _CAPTURE_FRAMES, useValue: false}
6568
];
Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
declare var exportFunction;
210
declare var unsafeWindow;
311

412
exportFunction(function() {
513
var curTime = unsafeWindow.performance.now();
614
(<any>self).port.emit('startProfiler', curTime);
7-
}, unsafeWindow, {defineAs: "startProfiler"});
15+
}, unsafeWindow, {defineAs: 'startProfiler'});
816

9-
exportFunction(function() { (<any>self).port.emit('stopProfiler'); }, unsafeWindow,
10-
{defineAs: "stopProfiler"});
17+
exportFunction(function() {
18+
(<any>self).port.emit('stopProfiler');
19+
}, unsafeWindow, {defineAs: 'stopProfiler'});
1120

1221
exportFunction(function(cb) {
1322
(<any>self).port.once('perfProfile', cb);
1423
(<any>self).port.emit('getProfile');
15-
}, unsafeWindow, {defineAs: "getProfile"});
24+
}, unsafeWindow, {defineAs: 'getProfile'});
1625

17-
exportFunction(function() { (<any>self).port.emit('forceGC'); }, unsafeWindow,
18-
{defineAs: "forceGC"});
26+
exportFunction(function() {
27+
(<any>self).port.emit('forceGC');
28+
}, unsafeWindow, {defineAs: 'forceGC'});
1929

2030
exportFunction(function(name) {
2131
var curTime = unsafeWindow.performance.now();
2232
(<any>self).port.emit('markStart', name, curTime);
23-
}, unsafeWindow, {defineAs: "markStart"});
33+
}, unsafeWindow, {defineAs: 'markStart'});
2434

2535
exportFunction(function(name) {
2636
var curTime = unsafeWindow.performance.now();
2737
(<any>self).port.emit('markEnd', name, curTime);
28-
}, unsafeWindow, {defineAs: "markEnd"});
38+
}, unsafeWindow, {defineAs: 'markEnd'});

modules/benchpress/src/firefox_extension/lib/main.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
var {Cc, Ci, Cu} = require('chrome');
210
var os = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
311
var ParserUtil = require('./parser_util');
@@ -25,7 +33,8 @@ class Profiler {
2533
return perfEvents;
2634
}
2735

28-
_mergeMarkerEvents(perfEvents: any[]): any[] {
36+
/** @internal */
37+
private _mergeMarkerEvents(perfEvents: any[]): any[] {
2938
this._markerEvents.forEach(function(markerEvent) { perfEvents.push(markerEvent); });
3039
return perfEvents;
3140
}
@@ -51,12 +60,13 @@ mod.PageMod({
5160
include: ['*'],
5261
contentScriptFile: data.url('installed_script.js'),
5362
onAttach: worker => {
54-
worker.port.on('startProfiler',
55-
(timeStarted) => profiler.start(/* = profiler memory */ 3000000, 0.1,
56-
['leaf', 'js', 'stackwalk', 'gc'], timeStarted));
63+
worker.port.on(
64+
'startProfiler',
65+
(timeStarted) => profiler.start(
66+
/* = profiler memory */ 3000000, 0.1, ['leaf', 'js', 'stackwalk', 'gc'], timeStarted));
5767
worker.port.on('stopProfiler', () => profiler.stop());
58-
worker.port.on('getProfile',
59-
() => worker.port.emit('perfProfile', profiler.getProfilePerfEvents()));
68+
worker.port.on(
69+
'getProfile', () => worker.port.emit('perfProfile', profiler.getProfilePerfEvents()));
6070
worker.port.on('forceGC', forceGC);
6171
worker.port.on('markStart', (name, timeStarted) => profiler.addStartEvent(name, timeStarted));
6272
worker.port.on('markEnd', (name, timeEnded) => profiler.addEndEvent(name, timeEnded));

modules/benchpress/src/firefox_extension/lib/parser_util.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
/**
210
* @param {Object} perfProfile The perf profile JSON object.
311
* @return {Object[]} An array of recognized events that are captured

modules/benchpress/src/firefox_extension/lib/test_helper.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
var q = require('q');
210
var FirefoxProfile = require('firefox-profile');
311
var jpm = require('jpm/lib/xpi');
@@ -36,9 +44,8 @@ exports.getFirefoxProfileWithExtension = function() {
3644
var savedCwd = process.cwd();
3745
process.chdir(absPackageJsonDir);
3846

39-
return jpm(packageJson)
40-
.then(xpiPath => {
41-
process.chdir(savedCwd);
42-
return exports.getFirefoxProfile(xpiPath);
43-
});
47+
return jpm(packageJson).then(xpiPath => {
48+
process.chdir(savedCwd);
49+
return exports.getFirefoxProfile(xpiPath);
50+
});
4451
};

modules/benchpress/src/measure_values.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import {Date, DateWrapper} from '@angular/facade/src/lang';
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
29
import {Map} from '@angular/facade/src/collection';
10+
import {Date, DateWrapper} from '@angular/facade/src/lang';
311

412
export class MeasureValues {
5-
constructor(public runIndex: number, public timeStamp: Date,
6-
public values: {[key: string]: any}) {}
13+
constructor(
14+
public runIndex: number, public timeStamp: Date, public values: {[key: string]: any}) {}
715

816
toJson() {
917
return {

modules/benchpress/src/metric.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
import {BaseException, WrappedException} from '@angular/facade/src/exceptions';
210

311
/**

modules/benchpress/src/metric/multi_metric.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
19
import {Injector, OpaqueToken} from '@angular/core/src/di';
2-
import {StringMapWrapper} from '@angular/facade/src/collection';
310
import {PromiseWrapper} from '@angular/facade/src/async';
11+
import {StringMapWrapper} from '@angular/facade/src/collection';
412

513
import {Metric} from '../metric';
614

@@ -9,14 +17,10 @@ export class MultiMetric extends Metric {
917
return [
1018
{
1119
provide: _CHILDREN,
12-
useFactory:(injector: Injector) => childTokens.map(token => injector.get(token)),
20+
useFactory: (injector: Injector) => childTokens.map(token => injector.get(token)),
1321
deps: [Injector]
1422
},
15-
{
16-
provide: MultiMetric,
17-
useFactory: children => new MultiMetric(children),
18-
deps: [_CHILDREN]
19-
}
23+
{provide: MultiMetric, useFactory: children => new MultiMetric(children), deps: [_CHILDREN]}
2024
];
2125
}
2226

@@ -48,7 +52,7 @@ export class MultiMetric extends Metric {
4852
}
4953
}
5054

51-
function mergeStringMaps(maps: { [key: string]: string }[]): Object {
55+
function mergeStringMaps(maps: {[key: string]: string}[]): Object {
5256
var result = {};
5357
maps.forEach(
5458
map => { StringMapWrapper.forEach(map, (value, prop) => { result[prop] = value; }); });

0 commit comments

Comments
 (0)