This small benchmark suite is dedicated to mesure & describe how compute time is spent when rendering an application like in SSR.
-
./main.ts
is the entry point to run the benchmark -
./src
contains a sample app that exports arender
function. -
This app render a table of variable size, which depends on data (
initData()
) -
This app is then rendered X numbers of times
-
Individual function calls are measured with
startMeasuring()
/stopMeasuring()
from the core package. -
If you add a new measure, make sure to add it also to the
levels
map for it to be represented correctly in the result
yarn bazel run //modules/ssr-benchmarks:run
yarn bazel run //modules/ssr-benchmarks:run_browser
This bazel target will build the benchmark, start a http-server with a html that will load the benckmark script. The benchmark script with this target will have DOM Emulation disabled. The result will be visible in the devtools console.
Note: Due to the CLI adding some polyfills, @angular/build is patched to disable DOM emulation and running server code inside a browser:
- removing an import from
node:module
inpolyfills.server.mjs
(withtail ...
) - removing the import of
platform-server/init
.
To run create a usable flame chart, prepare a narrowed run (like benchmarkRun(10000, 20);
).
Then in the performance tab of the devtools, trigger "Record & Reload" to generate a profile.
A target is dedicated to generate a v8 log that can be fed to the Deopt Explorer extension.
- Run
yarn bazel run //modules/ssr-benchmarks:run_deopt
, - open the project generated at the path after
Successfully ran all commands in test directory:
, - open the logfile in the extension
=== table with 10000 rows, with 1000 renders === βββββββββββ¬βββββββββββββββββββββββββββββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββββ¬ββββββββββββ β (index) β name β min β average β percentage β max β βββββββββββΌβββββββββββββββββββββββββββββββββββββββΌβββββββββββΌβββββββββββΌβββββββββββββΌββββββββββββ€ β 0 β ' renderApplication ' β '77.0ms' β '86.4ms' β '100.0%' β '259.2ms' β β 1 β ' β createServerPlatform ' β '0.0ms' β '0.1ms' β '0.1%' β '3.7ms' β β 2 β ' β bootstrap ' β '35.9ms' β '42.6ms' β '49.3%' β '138.4ms' β β 3 β ' β _render ' β '39.7ms' β '43.8ms' β '50.7%' β '124.9ms' β β 4 β ' β whenStable ' β '0.0ms' β '0.0ms' β '0.0%' β '0.0ms' β β 5 β ' β prepareForHydration ' β '13.1ms' β '14.8ms' β '17.1%' β '53.4ms' β β 6 β ' β insertEventRecordScript ' β '0.0ms' β '0.0ms' β '0.0%' β '0.0ms' β β 7 β ' β serializeTransferStateFactory' β '0.0ms' β '0.0ms' β '0.0%' β '0.1ms' β β 8 β ' β renderToString ' β '7.3ms' β '8.9ms' β '10.3%' β '41.8ms' β βββββββββββ΄βββββββββββββββββββββββββββββββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββββ΄ββββββββββββ
Note: The max measure is often an outlier of the first few measures, probably before the JIT optimisation happens