Skip to content

Commit 225914b

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 ac2d0c6 commit 225914b

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
@@ -407,6 +407,9 @@
407407
{
408408
"name": "PARAM_REGEX"
409409
},
410+
{
411+
"name": "PERF_MARK_STANDALONE"
412+
},
410413
{
411414
"name": "PLATFORM_DESTROY_LISTENERS"
412415
},

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
@@ -380,6 +380,9 @@
380380
{
381381
"name": "Observable"
382382
},
383+
{
384+
"name": "PERF_MARK_STANDALONE"
385+
},
383386
{
384387
"name": "PLATFORM_DESTROY_LISTENERS"
385388
},

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@
536536
{
537537
"name": "OutletInjector"
538538
},
539+
{
540+
"name": "PERF_MARK_STANDALONE"
541+
},
539542
{
540543
"name": "PLATFORM_DESTROY_LISTENERS"
541544
},

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)