mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
The `ng_rollup_bundle` rule has been replaced with a new rule called `app_bundle`. This rule replicates the Angular v13 optimization pipeline in the CLI, so that we can get better benchmarking results. Also the rule is much simpler to maintain as it relies on ESbuild. The old `ng_rollup_bundle` rule did rely on e.g. build-optimizer that no longer has an effect on v13 Angular packages, so technically size tests/symbol tests were no longer as correct as they were before. This commit fixes that. A couple of different changes and their explanation: * Language-service will no longer use the benchmark rule for creating its NPM bundles! It will use plain `rollup_bundle`. ESBuild would have been nice but the language-service relies on AMD that ESBuild cannot generate (yet?) * Service-worker ngsw-worker.js file was generated using the benchmark bundle rule. This is wrong. We will use a simple ESbuild rule in the future. The output is more predictable that way, and we can have a clear use of the benchmark bundle rule.. * A couple of benchmarks in `modules/` had to be updated to use e.g. `initTableUtils` calls. This is done because with the new rule, all files except for the entry-point are considered side-effect free. The utilities for benchmarks relied on side-effects in some transitively-loaded file (bad practice anyway IMO). We are now initializing the utilities using a proper init function that is exported... PR Close #44490 |
||
|---|---|---|
| .. | ||
| src | ||
| BUILD.bazel | ||
| e2e_test.bzl | ||
| README.md | ||
| tsconfig-build.json | ||
| tsconfig-e2e.json | ||
| tsconfig.json | ||
How to run the benchmarks locally
Run in the browser
yarn bazel run modules/benchmarks/src/tree/{name}:devserver
# e.g. "ng2" tree benchmark:
yarn bazel run modules/benchmarks/src/tree/ng2:devserver
Run e2e tests
# Run e2e tests of individual applications:
yarn bazel test modules/benchmarks/src/tree/ng2/...
# Run all e2e tests:
yarn bazel test modules/benchmarks/...
Use of *_aot.ts files
The *_aot.ts files are used as entry-points within Google to run the benchmark
tests. These are still built as part of the corresponding ng_module rule.
Specifying benchmark options
There are options that can be specified in order to control how a given benchmark target runs. The following options can be set through test environment variables:
PERF_SAMPLE_SIZE: Benchpress performs measurements untilscriptTimepredictively no longer decreases. It does this by using a simple linear regression with the amount of samples specified. Defaults to20samples.PERF_FORCE_GC: If set totrue,@angular/benchpresswill run run the garbage collector before and after performing measurements. Benchpress will measure and report the garbage collection time.PERF_DRYRUN: If set totrue, no results are printed and stored in ajsonfile. Also benchpress only performs a single measurement (unlike with the simple linear regression).
Here is an example command that sets the PERF_DRYRUN option:
yarn bazel test modules/benchmarks/src/tree/baseline:perf --test_env=PERF_DRYRUN=true