99import fs from 'node:fs' ;
1010import path from 'node:path' ;
1111import { type BenchmarkCliOptions , runI18nBenchmarks } from './benchmarks/i18n/index.mts' ;
12+ import {
13+ type LibraryBuilderBenchmarkOptions ,
14+ runLibraryBuilderBenchmarks ,
15+ } from './benchmarks/library-builder/index.mts' ;
1216
1317function checkBuildStatus ( logger : Console ) : boolean {
1418 const distFile = 'dist/@angular/build/src/tools/i18n/i18n-inliner.js' ;
@@ -36,6 +40,50 @@ function checkBuildStatus(logger: Console): boolean {
3640 return true ;
3741}
3842
43+ function parseIntList ( raw : string | undefined ) : number [ ] | undefined {
44+ return raw ?. split ( ',' ) . map ( ( s ) => Number ( s . trim ( ) ) ) ;
45+ }
46+
47+ async function runLibraryBuilderSubsystem ( options : {
48+ layout ?: string ;
49+ style ?: string ;
50+ sizes ?: string ;
51+ depths ?: string ;
52+ iterations ?: string | number ;
53+ json ?: boolean ;
54+ } ) : Promise < number > {
55+ if ( options . layout !== undefined && options . layout !== 'flat' && options . layout !== 'deep' ) {
56+ // eslint-disable-next-line no-console
57+ console . error ( `Error: --layout must be "flat" or "deep", got "${ options . layout } ".` ) ;
58+
59+ return 1 ;
60+ }
61+ if (
62+ options . style !== undefined &&
63+ ! [ 'inline' , 'inline-scss' , 'external' ] . includes ( options . style )
64+ ) {
65+ // eslint-disable-next-line no-console
66+ console . error (
67+ `Error: --style must be one of "inline", "inline-scss", "external", got "${ options . style } ".` ,
68+ ) ;
69+
70+ return 1 ;
71+ }
72+
73+ const cliOptions : LibraryBuilderBenchmarkOptions = {
74+ layout : options . layout as LibraryBuilderBenchmarkOptions [ 'layout' ] ,
75+ style : options . style as LibraryBuilderBenchmarkOptions [ 'style' ] ,
76+ sizes : parseIntList ( options . sizes ) ,
77+ depths : parseIntList ( options . depths ) ,
78+ iterations : options . iterations !== undefined ? Number ( options . iterations ) : undefined ,
79+ json : Boolean ( options . json ) ,
80+ } ;
81+
82+ const { exitCode } = await runLibraryBuilderBenchmarks ( cliOptions ) ;
83+
84+ return exitCode ;
85+ }
86+
3987export default async function (
4088 options : {
4189 _ ?: string [ ] ;
@@ -51,6 +99,10 @@ export default async function (
5199 'save-baseline' ?: string ;
52100 compareBaseline ?: string ;
53101 'compare-baseline' ?: string ;
102+ layout ?: string ;
103+ style ?: string ;
104+ sizes ?: string ;
105+ depths ?: string ;
54106 help ?: boolean ;
55107 [ key : string ] : unknown ;
56108 } ,
@@ -69,8 +121,9 @@ Usage:
69121
70122Subsystems:
71123 i18n Run i18n inliner performance benchmarks (default)
124+ library-builder Run @angular/build:library scaling benchmarks
72125
73- Options:
126+ Options (i18n) :
74127 --scenario=<name> Run a specific scenario (e.g. standard-app, enterprise-multilingual)
75128 --iterations=<n> Number of measured iterations (default: 5)
76129 --warmup=<n> Number of warmup iterations (default: 2)
@@ -80,15 +133,30 @@ Options:
80133 --json Output results in machine-readable JSON
81134 --save-baseline=<file> Save run results to a baseline JSON file
82135 --compare-baseline=<file> Compare run results against an existing baseline JSON file
136+
137+ Options (library-builder):
138+ --layout=<flat|deep> Fixture layout (default: flat)
139+ --style=<inline|inline-scss|external> Component style variant (default: inline)
140+ --sizes=<n,n,...> Entry-point counts to sweep, layout=flat only (default: 10,50,300,1000,2000)
141+ --depths=<n,n,...> Tree depths to sweep, layout=deep only (default: 2,5,8,11)
142+ --iterations=<n> Measured iterations per size (default: 2)
143+ --json Output raw measurements as JSON
144+
83145 --help Show this help message
84146` ) ;
85147
86148 return 0 ;
87149 }
88150
151+ if ( targetSubsystem === 'library-builder' ) {
152+ return runLibraryBuilderSubsystem ( options ) ;
153+ }
154+
89155 if ( targetSubsystem !== 'i18n' ) {
90156 // eslint-disable-next-line no-console
91- console . error ( `Unknown benchmark subsystem: "${ targetSubsystem } ". Supported subsystems: i18n` ) ;
157+ console . error (
158+ `Unknown benchmark subsystem: "${ targetSubsystem } ". Supported subsystems: i18n, library-builder` ,
159+ ) ;
92160
93161 return 1 ;
94162 }
0 commit comments