Performance benchmarks
The performance benchmark system measures how quickly Less turns representative Less input into CSS. It uses repeat runs, stable run conditions, feature-specific inputs, and historical compiler versions to show changes in compiler speed over time.
Benchmark corpus
Baseline corpus
The baseline corpus is a large, realistic stylesheet that exercises common Less work such as variables, mixins, nesting, color functions, and generated selectors. It gives the main benchmark a broad workload instead of measuring one small language feature.
References: packages/…/benchmark.less• L1-45 packages/…/benchmark.less• L99-145
Feature corpus
The feature corpus isolates newer language features so that a change can be studied apart from the large baseline. The files cover conditional and property lookup work from the v3 era, each() processing, and range() processing.
| Corpus | Main workload | Minimum version in historical runs |
|---|---|---|
| benchmark-v3.less | Conditions, boolean values, property access, and guarded mixins | 3.6.0 |
| benchmark-v37.less | List and map iteration with each() | 3.7.0 |
| benchmark-v39.less | Range generation across layout, color, and scale values | 3.9.0 |
References: packages/…/benchmark-v3.less• L1-42 packages/…/benchmark-v37.less• L1-39 packages/…/benchmark-v39.less• L1-47 packages/…/run-historical.sh• L49-51
Import scenarios
The import fixtures provide shared Less definitions and a reference-only stylesheet for focused import runs. They are copied into historical worktrees with the other benchmark assets, but they are not part of the default historical file list.
References: packages/…/benchmark-import-target.less• L1-43 packages/…/benchmark-import-reference-target.less• L1-82 packages/…/run-historical.sh• L326-334 packages/…/run-historical.sh• L352-364
Benchmark execution
Local phase measurements
The local benchmark entry point runs the current compiler against one selected input. It separates the work into parsing, evaluation, and final CSS rendering so a local result can show which compiler phase changed.
The entry point uses 30 runs by default and ignores the first five runs when it summarizes the result. It prints minimum time, maximum time, average time, variation, and input throughput for each phase.
References: packages/…/index.js• L7-21 packages/…/index.js• L26-52 packages/…/index.js• L55-83
Portable runner
The portable runner is the common command used inside different Less versions. It accepts a Less file, a run count, a warmup count, and optional compiler settings. It finds the compiler in layouts used by older releases and by the current package.
Its machine-readable result identifies the compiler and input. It then reports aggregate render measurements so the historical script can merge results without depending on human-readable console text.
References: packages/…/benchmark-runner.js• L1-5 packages/…/benchmark-runner.js• L21-59 packages/…/benchmark-runner.js• L61-79 packages/…/benchmark-runner.js• L107-130
Historical comparison flow
The historical runner compares the same corpus across tagged compiler releases. It uses an isolated worktree for each tag, prepares the release for use, runs only the files supported by that release, and stores one combined result set for the host machine.
This diagram shows how a selected release becomes a comparable result record.
sequenceDiagram
actor Engineer
participant Script as Historical runner
participant Worktree as Version worktree
participant Runner as Portable runner
participant Results as Result files
Engineer->>Script: Select versions, runs, and warmups
Script->>Worktree: Check out one release
Script->>Worktree: Prepare compiler and dependencies
Script->>Runner: Copy corpus and run supported files
Runner-->>Script: Return JSON measurements
Script->>Results: Append version record
Script->>Results: Copy latest host result and print summary
The default release set spans selected versions from v2.0.0 through v4.5.1. Older releases use one Node version and newer releases use another so each release can run in a supported environment. The runner also passes --math=always to keep division behavior aligned across versions.
References: packages/…/run-historical.sh• L4-35 packages/…/run-historical.sh• L65-81 packages/…/run-historical.sh• L178-231 packages/…/run-historical.sh• L269-323 packages/…/run-historical.sh• L368-375
Browser comparison coverage
The browser benchmark path creates pages for the current compiler and selected remote browser builds. It uses the baseline corpus to compare browser-side compilation for Less 2.7.3, 3.9.0, and 3.10.3 with the current version.
This path complements the Node-based historical runner. It measures the browser setting rather than adding those runs to the Node result files.
References: packages/…/benchmark.config.cjs• L2-12 packages/…/benchmark.config.cjs• L14-24 packages/…/benchmark.config.cjs• L26-48
Performance measurements
Timing model
The benchmark treats elapsed time as the main speed measure. The local phase view reports parser time, evaluation time, and total render time. The portable historical view reports the render aggregate because that is the stable result shared across compiler eras.
Warmup runs are excluded from the summary. The remaining samples produce minimum, maximum, average, median, standard deviation, sample count, and a variation percentage. Throughput expresses the input size processed per second in KB/s.
References: packages/…/index.js• L34-43 packages/…/index.js• L61-77 packages/…/benchmark-runner.js• L107-120 packages/…/macbook-pro_arm64.json• L21-38
Result records
Each historical result keeps the context needed to judge a timing value. The top-level record describes the host. Each version record names the release and Node version. Each benchmark record names the input, run counts, detected compiler, and measurements.
| Record level | Context used for comparison |
|---|---|
| Host | System ID, operating system, CPU, CPU count, memory when available, Node version, and run date |
| Compiler version | Git tag, normalized version, Node version, and run date |
| Benchmark input | Input name and size, compiler path, total runs, warmup runs, completed runs, and render statistics |
The runs directory preserves timestamped measurements. The latest directory holds the most recent result for each system ID, which makes the current host baseline easy to find without replacing the historical record.
References: packages/…/run-historical.sh• L96-125 packages/…/run-historical.sh• L152-171 packages/…/run-historical.sh• L404-431 packages/…/macbook-pro_arm64.json• L1-38
Comparison scope
A result is meaningful only when the input and execution context are comparable. Feature files are skipped below their minimum supported release, while missing tags, build failures, and compiler errors are recorded as skips or errors instead of being treated as timing data.
Use the host and Node metadata to separate compiler changes from changes in the machine or runtime. Use the median and spread with the average to judge whether a small difference is larger than normal run noise.
References: packages/…/run-historical.sh• L49-51 packages/…/run-historical.sh• L185-189 packages/…/run-historical.sh• L295-315 packages/…/run-historical.sh• L352-360 packages/…/run-historical.sh• L450-461
Related systems
- Compiler pipeline explains the parse, evaluate, and render stages that the local benchmark separates.
- Test and fixture system explains the wider role of input fixtures and generated checks.
- Packaging and builds explains the build and package context needed when comparing compiler releases.
Change checklist
When these files or sections are changed, remember to consider these:
- When a corpus file changes, preserve its role as a comparable workload and review its minimum-version gate in run-historical.sh.
- When the portable runner changes its JSON fields, update the historical result merge and summary together so failed or partial records remain visible.
- When compiler or math behavior changes, check the cross-version
--math=alwayssetting before comparing new timings with old records. - When release tags or Node selection changes, keep the host and runtime metadata clear enough to separate compiler changes from environment changes.
- When benchmark.less changes, consider both the Node historical runs and the browser benchmark configurations that use the same input.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The runner cannot find a compiler in the version worktree | The run exits without a measurement | Check the reported compiler search paths and run from the expected package directory. |
| A release does not support a feature corpus file | The file is not run for that release | Keep the file's minimum version aligned with the feature it exercises. |
| A tag is absent or its build cannot complete | That release is skipped and the comparison has a gap | Check the tag and inspect the per-version result record. |
| Runner output contains more than one JSON document | The historical merger records an error instead of timing data | Keep the runner result stream machine-readable and review error entries. |
| Host or Node versions differ between runs | Runtime noise can look like a compiler speed change | Compare records with matching system and runtime metadata. |
Key files
| File | Why to read it |
|---|---|
| packages/…/benchmark.less | Baseline workload for broad compiler performance. |
| packages/…/benchmark-v3.less | Feature workload for conditional and property-access behavior. |
| packages/…/benchmark-v37.less | Feature workload for each() processing. |
| packages/…/benchmark-v39.less | Feature workload for range() processing. |
| packages/…/benchmark-import-target.less and benchmark-import-reference-target.less | Supplementary inputs for import-focused measurements. |
| packages/…/index.js | Local phase-level benchmark entry point. |
| packages/…/benchmark-runner.js | Portable compiler runner and JSON result contract. |
| packages/…/run-historical.sh | Version selection, environment setup, execution flow, result storage, and summary output. |
| packages/…/benchmark.config.cjs | Browser benchmark coverage for current and selected historical versions. |
| packages/…/macbook-pro_arm64.json | Example of the stored host, version, input, and measurement record. |