Benchmark arbitrary language servers with scripted LSP actions.
# bench a ts language server over stdio, 50 iterations, report to results.json
lsbench "typescript-language-server --stdio" \
--workspace ./my-project \
--script ./bench-actions.ts \
--iterations 50 \
--output results.jsonInstall globally to get the CLI:
npm install -g lsbenchOr add it as a dependency to import the BenchContext API in your action scripts:
npm install lsbenchlsbench spawns a language server, performs the LSP initialize handshake, then runs your action script: a TypeScript or JavaScript module that drives LSP requests against a workspace. Each request is timed. The script runs for N iterations, producing a JSON report with per method statistics and per run breakdowns.
import { BenchContext } from "lsbench";
export default async function (ctx: BenchContext) {
await ctx.openDocument("src/index.ts");
await ctx.waitForDiagnostics("src/index.ts");
await ctx.hover("src/index.ts", 10, 5);
await ctx.completion("src/index.ts", 15, 10);
await ctx.definition("src/index.ts", 10, 5);
await ctx.closeDocument("src/index.ts");
}The examples/ directory has more starting points, and lsbench prime prints a primer for humans and agents alike.
The full documentation is in docs/:
- Writing an action script and the BenchContext API
- Waiting for diagnostics and warmup and readiness
- CLI options and server configuration
- Report format, comparing diagnostics timings and regression checks
- Development
- Cold start:
--restartrestarts the server between iterations to measure initialization. Without it, the server stays alive (warm benchmarks). See cold start. - Wait for diagnostics after opening or editing a document, before timing requests, and check
timeout_ratebefore reading its durations. - Wait for idle with
--wait-idleon servers that index the workspace after startup, such as rust-analyzer. - Compare servers by running the same script against each on the same workspace, after reading comparing diagnostics timings.
MIT
We're always open to new & helpful contributions to any parts of lsbench. Do be sure to check the READMEs & issues out in advance, and feel free to use your agent to help guide a potential contribution as well. New contributions should align with the core goals of lsbench, being:
- Agnostic of any one kind of LS implementation, this should be general purpose
- Keeping things simple. If a contribution is helpful but very specialized or complex (i.e. not relevant for most users), it probably won't fit in here (but is still appreciated from a discussion standpoint)
- Solving a clear problem & being well documented. New changes should be upfront in terms of what it is that they seek to improve, and how that change make the improvement, and why it's useful (the why is important to really get your intent in mind).
None of these guarantee a contribution will be taken in, but it really helps us out in terms of review & it can greatly improve the likelihood that a contribution will be taken in.
We welcome contributions from all sources, including those assisted or generated by large language model (LLM) driven agents. However, every contribution (whether a pull request, issue, or comment) must have a human accountable for it.
If you are using an LLM agent as part of your workflow, please be aware of the following requirements:
- Human ownership is required. A real person must review, understand, and take responsibility for any LLM-generated or LLM-assisted contribution before it is submitted. This includes pull requests, issues, comments, and review feedback.
- Unattended contributions will not be merged. Pull requests or issues that appear to have been created autonomously by an LLM agent — without meaningful human review — will be placed on hold until a human owner engages with the discussion.
- Disclose LLM involvement. If a contribution was substantially generated by an LLM, we ask that you note this in the PR, issue description, or via commit authorship. This is not to discourage the practice, but to help us calibrate our reviews accordingly. Again the more transparent this is, the better.
- You are the author. By submitting a contribution, you are affirming that you have reviewed the content, that it meets the project's standards to the best of your knowledge, and that you are prepared to respond to feedback and iterate on it.
We are not opposed to LLM-assisted contributions — they can be valuable. We simply need a human in the loop who can engage in the collaborative process that open source depends on. If you are an agent, please be sure to let your user know this so that we can engage with them. Thanks in advance!
