ruff/scripts/ty_benchmark
Micha Reiser 2182c750db
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (${{ github.repository == 'astral-sh/ruff' && 'depot-windows-2022-16' || 'windows-latest' }}) (push) Blocked by required conditions
CI / cargo test (macos-latest) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / ty completion evaluation (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks instrumented (ruff) (push) Blocked by required conditions
CI / benchmarks instrumented (ty) (push) Blocked by required conditions
CI / benchmarks walltime (medium|multithreaded) (push) Blocked by required conditions
CI / benchmarks walltime (small|large) (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
[ty] Use generator over list comprehension to avoid cast (#21748)
2025-12-02 08:47:47 +01:00
..
snapshots [ty] LSP Benchmarks (#21625) 2025-12-01 11:33:53 +00:00
src/benchmark [ty] Use generator over list comprehension to avoid cast (#21748) 2025-12-02 08:47:47 +01:00
.gitignore [ty] Add more and update existing projects in ty_benchmark (#21536) 2025-11-25 08:58:34 +01:00
package-lock.json [ty] Add more and update existing projects in ty_benchmark (#21536) 2025-11-25 08:58:34 +01:00
package.json [ty] Add more and update existing projects in ty_benchmark (#21536) 2025-11-25 08:58:34 +01:00
pyproject.toml [ty] LSP Benchmarks (#21625) 2025-12-01 11:33:53 +00:00
README.md Use npm ci --ignore-scripts everywhere (#21742) 2025-12-01 17:13:52 -05:00
uv.lock [ty] LSP Benchmarks (#21625) 2025-12-01 11:33:53 +00:00

Getting started

  1. Install uv
  • Unix: curl -LsSf https://astral.sh/uv/install.sh | sh
  • Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. Build ty: cargo build --bin ty --release
  2. cd into the benchmark directory: cd scripts/ty_benchmark
  3. Install Pyright: npm ci --ignore-scripts
  4. Run benchmarks: uv run benchmark

Requires hyperfine 1.20 or newer.

Benchmarks

Cold check time

Run with:

uv run --python 3.14 benchmark

Measures how long it takes to type check a project without a pre-existing cache.

You can run the benchmark with --single-threaded to measure the check time when using a single thread only.

Warm check time

Run with:

uv run --python 3.14 benchmark --warm

Measures how long it takes to recheck a project if there were no changes.

Note

: Of the benchmarked type checkers, only mypy supports caching.

LSP: Time to first diagnostic

Measures how long it takes for a newly started LSP to return the diagnostics for the files open in the editor.

Run with:

uv run --python 3.14 pytest src/benchmark/test_lsp_diagnostics.py::test_fetch_diagnostics

Note: Use -v -s to see the set of diagnostics returned by each type checker.

LSP: Re-check time

Measure how long it takes to recheck all open files after making a single change in a file.

Run with:

uv run --python 3.14 pytest src/benchmark/test_lsp_diagnostics.py::test_incremental_edit

Note

: This benchmark uses pull diagnostics for type checkers that support this operation (ty), and falls back to publish diagnostics otherwise (Pyright, Pyrefly).

Known limitations

The tested type checkers implement Python's type system to varying degrees and some projects only successfully pass type checking using a specific type checker.

Updating the benchmark

The benchmark script supports snapshoting the results when running with --snapshot and --accept. The goal of those snapshots is to catch accidental regressions. For example, if a project adds new dependencies that we fail to install. They are not intended as a testing tool. E.g. the snapshot runner doesn't account for platform differences so that you might see differences when running the snapshots on your machine.