File tree Expand file tree Collapse file tree 3 files changed +112
-0
lines changed
test/benchmarks/material/button Expand file tree Collapse file tree 3 files changed +112
-0
lines changed Original file line number Diff line number Diff line change
1
+ load ("@npm_angular_dev_infra_private//benchmark/component_benchmark:component_benchmark.bzl" , "component_benchmark" )
2
+
3
+ # TODO(wagnermaciel): Update this target to provide indigo-pink in a way that doesn't require having to import it with
4
+ # stylesUrls inside the components once `component_benchmark` supports asset injection.
5
+
6
+ component_benchmark (
7
+ name = "benchmark" ,
8
+ driver = ":button.perf-spec.ts" ,
9
+ driver_deps = [
10
+ "@npm//@angular/dev-infra-private" ,
11
+ "@npm//protractor" ,
12
+ "@npm//@types/jasmine" ,
13
+ ],
14
+ ng_deps = [
15
+ "@npm//@angular/core" ,
16
+ "@npm//@angular/platform-browser" ,
17
+ "//src/material/button" ,
18
+ "//src/cdk/a11y" ,
19
+ ],
20
+ ng_srcs = [":app.module.ts" ],
21
+ prefix = "" ,
22
+ styles = ["//src/material/prebuilt-themes:indigo-pink" ],
23
+ )
Original file line number Diff line number Diff line change
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
+ import { A11yModule } from '@angular/cdk/a11y' ;
9
+ import { Component , NgModule , ViewEncapsulation } from '@angular/core' ;
10
+ import { BrowserModule } from '@angular/platform-browser' ;
11
+ import { MatButtonModule } from '@angular/material/button' ;
12
+
13
+ /**
14
+ * @title Button benchmark component.
15
+ */
16
+ @Component ( {
17
+ selector : 'app-root' ,
18
+ template : `
19
+ <button id="show" (click)="show()">Show</button>
20
+ <button id="hide" (click)="hide()">Hide</button>
21
+
22
+ <ng-container *ngIf="isVisible">
23
+ <button mat-raised-button>Basic</button>
24
+ </ng-container>
25
+ ` ,
26
+ encapsulation : ViewEncapsulation . None ,
27
+ styleUrls : [ '//src/material/core/theming/prebuilt/indigo-pink.css' ] ,
28
+ } )
29
+ export class ButtonBenchmarkApp {
30
+ isChecked = false ;
31
+ isVisible = false ;
32
+
33
+ show ( ) { this . isVisible = true ; }
34
+ hide ( ) { this . isVisible = false ; }
35
+ }
36
+
37
+
38
+ @NgModule ( {
39
+ declarations : [ ButtonBenchmarkApp ] ,
40
+ imports : [
41
+ A11yModule ,
42
+ BrowserModule ,
43
+ MatButtonModule ,
44
+ ] ,
45
+ providers : [ ] ,
46
+ bootstrap : [ ButtonBenchmarkApp ]
47
+ } )
48
+ export class AppModule { }
Original file line number Diff line number Diff line change
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 '@angular/dev-infra-private/benchmark/driver-utilities' ;
11
+
12
+ describe ( 'button performance benchmarks' , ( ) => {
13
+ beforeAll ( ( ) => {
14
+ browser . rootEl = '#root' ;
15
+ } ) ;
16
+
17
+ it ( 'renders a basic raised button' , async ( ) => {
18
+ await runBenchmark ( {
19
+ id : 'button-render' ,
20
+ url : '' ,
21
+ ignoreBrowserSynchronization : true ,
22
+ params : [ ] ,
23
+ setup : async ( ) => await $ ( '#show' ) . click ( ) ,
24
+ prepare : async ( ) => await $ ( '#hide' ) . click ( ) ,
25
+ work : async ( ) => await $ ( '#show' ) . click ( ) ,
26
+ } ) ;
27
+ } ) ;
28
+
29
+ it ( 'clicks a basic raised button' , async ( ) => {
30
+ await runBenchmark ( {
31
+ id : 'button-click' ,
32
+ url : '' ,
33
+ ignoreBrowserSynchronization : true ,
34
+ params : [ ] ,
35
+ setup : async ( ) => await $ ( '#show' ) . click ( ) ,
36
+ work : async ( ) => {
37
+ await $ ( '.mat-raised-button' ) . click ( ) ;
38
+ } ,
39
+ } ) ;
40
+ } ) ;
41
+ } ) ;
You can’t perform that action at this time.
0 commit comments