Benches
Benches are run separately from tests and don't require any special setup. If the below file was benches.ts, you could run it using something like node benches.ts or tsx benches.ts:
Baseline expressions
If you're benchmarking an API, you'll need to include a "baseline expression" so that instantiations created when your API is initially invoked don't add noise to the individual tests.
Here's an example of what that looks like:
Be sure your baseline expression is not identical to an expression you are using in any of your benchmarks. If it is, the individual benchmarks will reuse its cached types, leading to reduced (or 0) instantiations.
Thresholds
If you'd like to fail in CI above a threshold, you can add flags like the following (default value is 20%, but it will not throw unless --benchErrorOnThresholdExceeded is set):