Skip to content

Commit 877ba3e

Browse files
pkozlowski-opensourcealxhub
authored andcommitted
refactor(core): use performance API for control flow and standalone (angular#52370)
This commit adds a standard performance marker that can be viewed in Chrome dev tools and other tooling. See more info at https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark PR Close angular#52370
1 parent 3861a73 commit 877ba3e

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

packages/core/src/render3/features/standalone_feature.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ class StandaloneService implements OnDestroy {
6060
});
6161
}
6262

63+
const PERF_MARK_STANDALONE = {
64+
detail: {feature: 'NgStandalone'}
65+
};
66+
6367
/**
6468
* A feature that acts as a setup code for the {@link StandaloneService}.
6569
*
@@ -71,6 +75,7 @@ class StandaloneService implements OnDestroy {
7175
* @codeGenApi
7276
*/
7377
export function ɵɵStandaloneFeature(definition: ComponentDef<unknown>) {
78+
performance.mark('mark_use_counter', PERF_MARK_STANDALONE);
7479
definition.getStandaloneInjector = (parentInjector: EnvironmentInjector) => {
7580
return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
7681
};

packages/core/src/render3/instructions/control_flow.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import {addLViewToLContainer, createAndRenderEmbeddedLView, getLViewFromLContain
2424

2525
import {ɵɵtemplate} from './template';
2626

27+
const PERF_MARK_CONTROL_FLOW = {
28+
detail: {feature: 'NgControlFlow'}
29+
};
30+
2731
/**
2832
* The conditional instruction represents the basic building block on the runtime side to support
2933
* built-in "if" and "switch". On the high level this instruction is responsible for adding and
@@ -36,6 +40,8 @@ import {ɵɵtemplate} from './template';
3640
* @codeGenApi
3741
*/
3842
export function ɵɵconditional<T>(containerIndex: number, matchingTemplateIndex: number, value?: T) {
43+
performance.mark('mark_use_counter', PERF_MARK_CONTROL_FLOW);
44+
3945
const hostLView = getLView();
4046
const bindingIndex = nextBindingIndex();
4147
const lContainer = getLContainer(hostLView, HEADER_OFFSET + containerIndex);
@@ -132,6 +138,8 @@ export function ɵɵrepeaterCreate(
132138
index: number, templateFn: ComponentTemplate<unknown>, decls: number, vars: number,
133139
trackByFn: TrackByFunction<unknown>, trackByUsesComponentInstance?: boolean,
134140
emptyTemplateFn?: ComponentTemplate<unknown>, emptyDecls?: number, emptyVars?: number): void {
141+
performance.mark('mark_use_counter', PERF_MARK_CONTROL_FLOW);
142+
135143
const hasEmptyBlock = emptyTemplateFn !== undefined;
136144
const hostLView = getLView();
137145
const boundTrackBy = trackByUsesComponentInstance ?

packages/core/test/bundling/animations-standalone/bundle.golden_symbols.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@
404404
{
405405
"name": "PARAM_REGEX"
406406
},
407+
{
408+
"name": "PERF_MARK_STANDALONE"
409+
},
407410
{
408411
"name": "PLATFORM_DESTROY_LISTENERS"
409412
},

packages/core/test/bundling/defer/bundle.golden_symbols.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@
374374
{
375375
"name": "Observable"
376376
},
377+
{
378+
"name": "PERF_MARK_STANDALONE"
379+
},
377380
{
378381
"name": "PLATFORM_DESTROY_LISTENERS"
379382
},

packages/core/test/bundling/hydration/bundle.golden_symbols.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@
374374
{
375375
"name": "Observable"
376376
},
377+
{
378+
"name": "PERF_MARK_STANDALONE"
379+
},
377380
{
378381
"name": "PLATFORM_DESTROY_LISTENERS"
379382
},

packages/core/test/bundling/router/bundle.golden_symbols.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@
527527
{
528528
"name": "OutletInjector"
529529
},
530+
{
531+
"name": "PERF_MARK_STANDALONE"
532+
},
530533
{
531534
"name": "PLATFORM_DESTROY_LISTENERS"
532535
},

packages/core/test/bundling/standalone_bootstrap/bundle.golden_symbols.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@
296296
{
297297
"name": "Observable"
298298
},
299+
{
300+
"name": "PERF_MARK_STANDALONE"
301+
},
299302
{
300303
"name": "PLATFORM_DESTROY_LISTENERS"
301304
},

0 commit comments

Comments
 (0)