Skip to content

Commit 98ded94

Browse files
pkozlowski-opensourcejasonaden
authored andcommitted
fixup! test(ivy): make the test run with benchpress (angular#30449)
PR Close angular#30449
1 parent a5a1f4f commit 98ded94

File tree

6 files changed

+51
-42
lines changed

6 files changed

+51
-42
lines changed

modules/benchmarks/src/expanding_rows/BUILD.bazel

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
22

3+
load("//tools:defaults.bzl", "ts_library")
34
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
45
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
56
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
@@ -8,7 +9,7 @@ ng_module(
89
name = "application_lib",
910
srcs = glob(
1011
["**/*.ts"],
11-
exclude = ["**/*_spec.ts"],
12+
exclude = ["**/*.spec.ts"],
1213
),
1314
deps = [
1415
"//packages:types",
@@ -19,14 +20,13 @@ ng_module(
1920
],
2021
)
2122

22-
ng_module(
23-
name = "application_spec",
24-
srcs = glob(["**/*_spec.ts"]),
23+
ts_library(
24+
name = "perf_lib",
25+
testonly = 1,
26+
srcs = ["benchmark_perf.spec.ts"],
2527
deps = [
26-
"//packages:types",
27-
"//packages/common",
28-
"//packages/core",
29-
"@npm//reflect-metadata",
28+
"//modules/e2e_util",
29+
"@npm//protractor",
3030
],
3131
)
3232

@@ -69,6 +69,6 @@ benchmark_test(
6969
name = "perf",
7070
server = ":prodserver",
7171
deps = [
72-
":application_spec",
72+
":perf_lib",
7373
],
7474
)

modules/benchmarks/src/expanding_rows/benchmark.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {BenchmarkableExpandingRowModule} from './benchmarkable_expanding_row_mod
2222
2323
<section>
2424
<button id="reset" (click)="reset()">Reset</button>
25-
<button (click)="handleInitClick()">Init</button>
25+
<button id="init" (click)="init()">Init</button>
2626
<button id="run" (click)="runAll()">Run All</button>
2727
</section>
2828
@@ -38,6 +38,8 @@ export class InitializationRoot implements AfterViewInit {
3838

3939
reset() { this.expandingRow.reset(); }
4040

41+
init() { this.expandingRow.init(); }
42+
4143
async runAll() {
4244
await execTimed('initialization_benchmark', async() => { await this.doInit(); });
4345
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
import {$, browser} from 'protractor';
10+
import {runBenchmark} from '../../../e2e_util/perf_util';
11+
12+
describe('benchmarks', () => {
13+
14+
it('should work for create', done => {
15+
browser.rootEl = '#root';
16+
runBenchmark({
17+
id: 'create',
18+
url: '',
19+
ignoreBrowserSynchronization: true,
20+
params: [],
21+
prepare: () => $('#reset').click(),
22+
work: () => $('#init').click()
23+
}).then(done, done.fail);
24+
});
25+
26+
});

modules/benchmarks/src/expanding_rows/benchmark_spec.ts

-24
This file was deleted.

modules/benchmarks/src/expanding_rows/index.html

+12-7
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,24 @@ <h1>Change Detection Benchmark</h1>
1414
<benchmark-root>loading...</benchmark-root>
1515

1616
<script>
17+
window.ngDevMode = location.hash == '#ngDevMode';
1718
addEventListener('DOMContentLoaded', () => {
18-
window.ngDevMode = location.hash == '#ngDevMode';
1919
// DevServer has automatic bootstrap code, so if we already have <scripts> than we don't need to bootstrap
2020
var alreadyBootstraped = document.querySelectorAll('script').length > 1; // 1 for ourselves
21-
2221
if (!alreadyBootstraped) {
2322
function loadScript(url) {
24-
var script = document.createElement('script');
25-
script.src = url;
26-
document.body.append(script);
23+
return new Promise(function (resolve, reject) {
24+
var script = document.createElement('script');
25+
script.src = url;
26+
script.onload = resolve;
27+
script.onerror = reject;
28+
document.body.append(script);
29+
});
2730
}
28-
loadScript('/npm/node_modules/zone.js/dist/zone.js');
29-
loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.js');
31+
// zone.js must be loaded and processed before Angular bundle gets executed
32+
loadScript('/npm/node_modules/zone.js/dist/zone.js').then(function () {
33+
loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.js');
34+
});
3035
}
3136
});
3237
</script>

protractor-perf.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports.config = {
3434
framework: 'jasmine2',
3535
jasmineNodeOpts: {
3636
showColors: true,
37-
defaultTimeoutInterval: 60000,
37+
defaultTimeoutInterval: 90000,
3838
print: function(msg) { console.log(msg); },
3939
},
4040
useAllAngular2AppRoots: true

0 commit comments

Comments
 (0)