sway/scripts/csv2html
Igor Rončević 46e83a6fbe
Some checks are pending
CI / build-sway-lib-std (push) Waiting to run
CI / forc-fmt-check-sway-lib-std (push) Waiting to run
CI / forc-fmt-check-sway-examples (push) Waiting to run
CI / forc-fmt-check-panic (push) Waiting to run
CI / check-sdk-harness-test-suite-compatibility (push) Waiting to run
CI / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-fmt-check (push) Waiting to run
CI / cargo-run-e2e-test (push) Blocked by required conditions
CI / cargo-test-lib-std (push) Waiting to run
CI / forc-pkg-fuels-deps-check (push) Waiting to run
Codspeed Benchmarks / benchmarks (push) Waiting to run
CI / verifications-complete (push) Blocked by required conditions
CI / check-dependency-version-formats (push) Waiting to run
CI / check-forc-manifest-version (push) Waiting to run
CI / get-fuel-core-version (push) Waiting to run
CI / build-sway-examples (push) Waiting to run
CI / build-reference-examples (push) Waiting to run
CI / build-mdbook (push) Waiting to run
CI / build-forc-doc-sway-lib-std (push) Waiting to run
CI / build-forc-test-project (push) Waiting to run
CI / cargo-build-workspace (push) Waiting to run
CI / cargo-clippy (push) Waiting to run
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / forc-run-benchmarks (push) Waiting to run
CI / forc-unit-tests (push) Waiting to run
CI / Build and test various forc tools (push) Blocked by required conditions
CI / cargo-unused-deps-check (push) Waiting to run
CI / notify-slack-on-failure (push) Blocked by required conditions
CI / pre-publish-check (push) Waiting to run
CI / publish (push) Blocked by required conditions
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
Add --perf option to test to collect and diff performance data (#7459)
## Description

This PR:
- Adds `--perf` and `--perf-only` options to `test` to collect gas
usages and bytecode sizes, and to run only the tests that actually
produce those performance data, respectively.
- Adds `[performance]` recipes to `justfile` that fully automate a
workflow for collecting and comparing performance data of the compiler
output.

`--perf` flag instructs `test` to collect performance data from tests of
categories `compile`, `run`, and `unit_tests_pass`. Collected gas usages
and bytecode sizes are written to files named
`<timestamp>-<category>-<build profile>-<branch>.csv`. E.g.:
`1020165605-e2e-bytecode-sizes-release-master.csv`.

When running tests in parallel (default option), performance data of
each individual `test --exact <test_toml_path>` process is written to a
piped stdout in JSON format. The main `test` process collects those JSON
outputs from all spanned processes.

The usual workflow of collecting and comparing performance data between
the `master` and feature branch is supported by the following `just`
recipes:

```console
[performance]
perf-e2e filter=''                    # collect gas usages and bytecode sizes from E2E tests [alias: pe2e]
perf-in-lang filter=''                # collect gas usages from in-language tests [alias: pil]
perf-all filter=''                    # collect gas usages and bytecode sizes from all tests (E2E and in-language) [alias: pa]
perf-diff before after format='md'    # generate performance diff between two CSV files [alias: pd]
perf-diff-latest format='md'          # generate performance diffs between the latest two CSV files per testing category [alias: pdl]
perf-snapshot-historical path open='' # collect historic gas usages from a snapshot test that has a `forc test` output [alias: psh]
perf-list                             # list all performance files (*gas-usages-*.* and *bytecode-sizes-*.*) [alias: pl]
perf-remove                           # remove all performance files (*gas-usages-*.* and *bytecode-sizes-*.*) [alias: pr]
```

To obtain the performance comparison it is enough to run:

```console
just pa   // `just perf-all`. On `master` to get the baseline.
just pa   // `just perf-all`. On the feature branch to get the improved data.
just pdl  // `just perf-diff-latest`. To get the diff of the last two collected performance data sets.
```
The `just` recipes should be executed from the root of the Sway
repository.

Aside from `--perf` writing to predefined files, all other parts of the
workflow are `just` recipes and can potentially be tailored to any other
workflow.

Adding support for collecting gas usages and bytecode sizes from other
tests like (snapshot, in-language, SDK harness) will be added in follow
up PRs.

## Checklist

- [ ] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2025-10-21 18:41:35 +04:00
..
csv2html.sh Add --perf option to test to collect and diff performance data (#7459) 2025-10-21 18:41:35 +04:00