Skip to content

Commit

Permalink
test(ivy): benchpress
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource committed May 15, 2019
1 parent 877d0d5 commit 842db56
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 40 deletions.
18 changes: 9 additions & 9 deletions modules/benchmarks/src/expanding_rows/BUILD.bazel
@@ -1,5 +1,6 @@
package(default_visibility = ["//modules/benchmarks:__subpackages__"])

load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
Expand All @@ -8,7 +9,7 @@ ng_module(
name = "application_lib",
srcs = glob(
["**/*.ts"],
exclude = ["**/*_spec.ts"],
exclude = ["**/*.spec.ts"],
),
deps = [
"//packages:types",
Expand All @@ -19,14 +20,13 @@ ng_module(
],
)

ng_module(
name = "application_spec",
srcs = glob(["**/*_spec.ts"]),
ts_library(
name = "perf_lib",
testonly = 1,
srcs = ["benchmark_perf.spec.ts"],
deps = [
"//packages:types",
"//packages/common",
"//packages/core",
"@npm//reflect-metadata",
"//modules/e2e_util",
"@npm//protractor",
],
)

Expand Down Expand Up @@ -69,6 +69,6 @@ benchmark_test(
name = "perf",
server = ":prodserver",
deps = [
":application_spec",
":perf_lib",
],
)
4 changes: 3 additions & 1 deletion modules/benchmarks/src/expanding_rows/benchmark.ts
Expand Up @@ -22,7 +22,7 @@ import {BenchmarkableExpandingRowModule} from './benchmarkable_expanding_row_mod
<section>
<button id="reset" (click)="reset()">Reset</button>
<button (click)="handleInitClick()">Init</button>
<button id="init" (click)="init()">Init</button>
<button id="run" (click)="runAll()">Run All</button>
</section>
Expand All @@ -38,6 +38,8 @@ export class InitializationRoot implements AfterViewInit {

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

init() { this.expandingRow.init(); }

async runAll() {
await execTimed('initialization_benchmark', async() => { await this.doInit(); });
}
Expand Down
26 changes: 26 additions & 0 deletions modules/benchmarks/src/expanding_rows/benchmark_perf.spec.ts
@@ -0,0 +1,26 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {$, browser} from 'protractor';
import {runBenchmark} from '../../../e2e_util/perf_util';

describe('benchmarks', () => {

it('should work for create', done => {
browser.rootEl = '#root';
runBenchmark({
id: 'create',
url: '',
ignoreBrowserSynchronization: true,
params: [],
prepare: () => $('#reset').click(),
work: () => $('#init').click()
}).then(done, done.fail);
});

});
24 changes: 0 additions & 24 deletions modules/benchmarks/src/expanding_rows/benchmark_spec.ts

This file was deleted.

13 changes: 8 additions & 5 deletions modules/benchmarks/src/expanding_rows/index.html
Expand Up @@ -14,22 +14,25 @@ <h1>Change Detection Benchmark</h1>
<benchmark-root>loading...</benchmark-root>

<script>
window.ngDevMode = location.hash == '#ngDevMode';
addEventListener('DOMContentLoaded', () => {
window.ngDevMode = location.hash == '#ngDevMode';
// DevServer has automatic bootstrap code, so if we already have <scripts> than we don't need to bootstrap
var alreadyBootstraped = document.querySelectorAll('script').length > 1; // 1 for ourselves

if (!alreadyBootstraped) {
function loadScript(url) {
function loadScript(url, async) {
var script = document.createElement('script');
script.src = url;
script.setAttribute("async", async);
document.body.append(script);
}
loadScript('/npm/node_modules/zone.js/dist/zone.js');
loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.js');
loadScript('/npm/node_modules/zone.js/dist/zone.js', false);
loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.js', false);
}
});
</script>
<!-- TODO(pk): this will break devserver but I can't make scripts loading working reliably under benchpress -->
<script src="/npm/node_modules/zone.js/dist/zone.js"></script>
<script src="bundle.min.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion protractor-perf.conf.js
Expand Up @@ -34,7 +34,7 @@ exports.config = {
framework: 'jasmine2',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 60000,
defaultTimeoutInterval: 90000,
print: function(msg) { console.log(msg); },
},
useAllAngular2AppRoots: true
Expand Down

0 comments on commit 842db56

Please sign in to comment.