Files
Kigi-CLI/crates/codegen/kigi-codebase-graph/src/bin/bench_index.rs
T
ZacharyZhang-NY a02b555e66 docs(comments): rewrite comments across all crates to the guidelines
Sweep every first-party crate source (1956 .rs files) to the project comment
guidelines: delete redundant restatements, decorative banners, change
narration, and end-of-line comments; keep and tighten the crucial ones
(invariants, bug rationale, SAFETY blocks, ported-source attribution).

No functional code changed. Every edit is proven comment-only against the
prior tree by a comment-stripping lexer (string/char/raw-string aware) plus a
separate doctest-fence check. Where removing a comment made rustfmt or clippy
want to re-lay-out adjacent code, the minimal triggering comment is restored so
code tokens stay byte-identical.

Gates green: cargo fmt --all --check (0 diffs), cargo check and cargo clippy
--workspace --all-targets (0 warnings).

Adds scripts/check_codegen_comment_guidelines.py — the enforcement gate for
these guidelines (flags banners, end-of-line comments, change narration, and
commented-out code).
2026-07-23 16:55:39 -04:00

64 lines
1.9 KiB
Rust

//! Benchmark binary for index building.
use std::path::Path;
use std::time::Instant;
use kigi_codebase_graph::{IndexBuilder, LanguageRegistry};
// Use mimalloc for faster allocation in multi-threaded workloads
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn main() {
let args: Vec<String> = std::env::args().collect();
let path = if let Some(p) = args.get(1) {
p.clone()
} else if let Ok(p) = std::env::var("BENCH_REPO_ROOT").or_else(|_| std::env::var("XAI_ROOT")) {
p
} else {
eprintln!("Usage: bench_index <path>");
eprintln!("Or set BENCH_REPO_ROOT to a large checkout to bench against");
std::process::exit(1);
};
println!("Verifying query compilation...");
let registry = LanguageRegistry::new();
for ext in &["ts", "tsx", "js", "jsx", "rs", "go", "py"] {
match registry.for_extension(ext) {
Some(config) => match config.compile_query() {
Ok(query) => {
println!(" .{}: OK ({} patterns)", ext, query.pattern_count());
}
Err(e) => {
println!(" .{}: FAILED - {:?}", ext, e);
}
},
None => println!(" .{}: NOT SUPPORTED", ext),
}
}
println!();
let root_path = Path::new(&path);
println!("Building index for: {}", root_path.display());
let start = Instant::now();
let index = IndexBuilder::new()
.build(root_path)
.expect("Failed to build index");
let elapsed = start.elapsed();
let (file_count, defs, refs) = index.stats();
println!("Files indexed: {}", file_count);
println!(
"Indexed {} definitions, {} references in {:?}",
defs, refs, elapsed
);
println!("Aliases: {}", index.alias_count());
println!(
"Files/sec: {:.0}",
file_count as f64 / elapsed.as_secs_f64()
);
}