Skip to content

Commit 99f56e1

Browse files
authored
feat: add comprehensive performance benchmarks with criterion (#21)
* feat: add comprehensive performance benchmarks with criterion * docs: update READMEs with latest features and architecture * fix: add #[non_exhaustive] to enums for semver compliance
1 parent 4ab6b4e commit 99f56e1

File tree

19 files changed

+2044
-32
lines changed

19 files changed

+2044
-32
lines changed

Cargo.lock

Lines changed: 293 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ A universal Language Server Protocol (LSP) server for dependency management acro
2424

2525
| Ecosystem | Manifest File | Status |
2626
|-----------|---------------|--------|
27-
| Rust/Cargo | `Cargo.toml` | Supported |
28-
| npm | `package.json` | Supported |
29-
| Python/PyPI | `pyproject.toml` | Planned |
27+
| Rust/Cargo | `Cargo.toml` | ✅ Supported |
28+
| npm | `package.json` | ✅ Supported |
29+
| Python/PyPI | `pyproject.toml` | ✅ Supported |
30+
31+
> [!NOTE]
32+
> PyPI support includes PEP 621, PEP 735 (dependency-groups), and Poetry formats.
3033
3134
## Installation
3235

@@ -155,15 +158,43 @@ cargo deny check
155158
```
156159
deps-lsp/
157160
├── crates/
158-
│ ├── deps-core/ # Shared types, cache, error handling
161+
│ ├── deps-core/ # Shared traits, cache, generic handlers
159162
│ ├── deps-cargo/ # Cargo.toml parser + crates.io registry
160163
│ ├── deps-npm/ # package.json parser + npm registry
164+
│ ├── deps-pypi/ # pyproject.toml parser + PyPI registry
161165
│ ├── deps-lsp/ # Main LSP server
162166
│ └── deps-zed/ # Zed extension (WASM)
163167
├── .config/ # nextest configuration
164168
└── .github/ # CI/CD workflows
165169
```
166170

171+
### Architecture
172+
173+
The codebase uses a trait-based architecture with the `EcosystemHandler` trait providing a unified interface for all package ecosystems:
174+
175+
```rust
176+
// Each ecosystem implements EcosystemHandler
177+
impl EcosystemHandler for CargoHandler { ... }
178+
impl EcosystemHandler for NpmHandler { ... }
179+
impl EcosystemHandler for PyPiHandler { ... }
180+
181+
// Generic LSP handlers work with any ecosystem
182+
generate_inlay_hints::<H: EcosystemHandler>(...);
183+
generate_hover_info::<H: EcosystemHandler>(...);
184+
generate_code_actions::<H: EcosystemHandler>(...);
185+
generate_diagnostics::<H: EcosystemHandler>(...);
186+
```
187+
188+
### Benchmarks
189+
190+
Run performance benchmarks with criterion:
191+
192+
```bash
193+
cargo bench --workspace
194+
```
195+
196+
View HTML report: `open target/criterion/report/index.html`
197+
167198
## License
168199

169200
[MIT](LICENSE)

crates/deps-cargo/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ tracing = { workspace = true }
2020
urlencoding = { workspace = true }
2121

2222
[dev-dependencies]
23+
criterion = { workspace = true, features = ["html_reports"] }
2324
insta = { workspace = true, features = ["json"] }
2425
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
26+
27+
[[bench]]
28+
name = "cargo_benchmarks"
29+
harness = false

crates/deps-cargo/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This crate provides parsing and registry integration for Rust's Cargo ecosystem.
1515
- **crates.io Registry** — Sparse index client for package metadata
1616
- **Version Resolution** — Semver-aware version matching
1717
- **Workspace Support** — Handle `workspace.dependencies` inheritance
18+
- **EcosystemHandler** — Implements `deps_core::EcosystemHandler` trait
1819

1920
## Usage
2021

@@ -24,9 +25,21 @@ deps-cargo = "0.2"
2425
```
2526

2627
```rust
27-
use deps_cargo::{CargoParser, CratesIoRegistry};
28+
use deps_cargo::{parse_cargo_toml, CratesIoRegistry};
29+
30+
let dependencies = parse_cargo_toml(content)?;
31+
let registry = CratesIoRegistry::new(cache);
32+
let versions = registry.get_versions("serde").await?;
2833
```
2934

35+
## Benchmarks
36+
37+
```bash
38+
cargo bench -p deps-cargo
39+
```
40+
41+
Parsing performance: ~4μs for small files, ~55μs for large files (100+ dependencies).
42+
3043
## License
3144

3245
[MIT](../../LICENSE)

0 commit comments

Comments
 (0)