Time Complexity Calculator by VoidHub
An offline VS Code / Kiro extension for estimating C++ worst-case time and auxiliary space complexity. Select code and press Ctrl+Alt+C (macOS: Cmd+Alt+C), or use the Calculate Complexity CodeLens above a function.
The analyzer explains the rules behind each result. It supports canonical loops, selected STL operations, same-file helper calls, several recurrence patterns, and common competitive-programming structures. Unsupported code can return Unknown.
Requirements and parser modes
- The extension runs locally. Source code is not sent to a server.
- Clang provides the typed AST used for the main analysis. Install LLVM/Clang and use
projectX.clangPath if automatic discovery does not find it.
- Without Clang, a limited TypeScript parser can analyze basic supported functions. Its results are marked estimated, and unsupported syntax is withheld. It does not provide the same C++ coverage as Clang.
- The display confidence score is derived from rules. 99% is not a measured probability that an answer is correct.
Benchmark status
The current dataset contains 28,760 cases in 1,461 manifests. It includes generated variants; the number of cases is not the number of independent algorithms or independently reviewed programs.
The saved holdout list selects 175 cases in 46 manifests. This does not meet the project's documented gate of 1,000 independent hidden holdout cases for a public precision claim. The former 98% badge and historical accuracy table have been removed pending a reproducible audit.
The packaged 1.0.2 engine matched 64 of 125 asserted profiles (51.2%) on the saved 175-case holdout, with 71.4% coverage. This measures agreement with existing labels; both analyzer errors and label discrepancies remain. The earlier 97.5% development result came from an intermediate build and is not a final-release accuracy claim.
Benchmark terminology:
- Label agreement compares both time and space to manifest labels and may include matching Unknown values.
- Asserted profile precision counts matching time/space profiles among all non-abstaining answers, including correct profiles reported with softer confidence.
- Coverage is the fraction receiving both a time and space assertion.
- A disagreement requires inspection of the source and label; it does not by itself prove which one is wrong.
Recurrence output preserves exact characteristic roots: phi is the golden ratio, and root(d1,...,dk) is the unique number r > 1 satisfying the sum of r^(-di) = 1. Decimal exponential bases are never rounded for display or multiplication.
Notation comparison preserves independent input dimensions and exponential bases. It does not assume graph connectivity or rename dimensions separately in each expression. Benchmark reports describe corpus agreement, not correctness for arbitrary C++.
Settings
| Setting |
Purpose |
projectX.enableCodeLens |
Show complexity actions above functions |
projectX.enableHover |
Show analysis when hovering over function names |
projectX.minimumConfidence |
Minimum rule score displayed; default 80 |
projectX.clangPath |
Optional Clang executable path |
projectX.analyzerPath |
Optional analyzer CLI override |
projectX.nativeAnalyzerPath |
Optional locally built LibTooling executable |
Development and verification
npm ci
npm run build
npm test
npm run validate:dataset
npm run benchmark:dataset -- --summary --output=benchmarks/results/current.json
Use --manifest=NAME.manifest.json for a subset, --dev for the saved development split, and --holdout for the saved holdout. Reports record corpus and engine hashes. To measure the limited parser explicitly, set PROJECT_X_PARSER=fallback in the shell running the benchmark.
Version 1.0.2 includes the revised mathematical growth icon, parser safety fixes, corrected allocation accounting, recurrence fixes, and benchmark reporting improvements.
Source repository · VoidHub
Licensed under the MIT License.