Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions crates/inspect-cli/src/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::process::Command;
use clap::Args;
use sem_core::git::types::DiffScope;

use inspect_core::analyze::analyze;
use inspect_core::analyze::{analyze_with_graph, build_analysis_graph};
use inspect_core::types::RiskLevel;

use serde::Serialize;
Expand All @@ -27,6 +27,10 @@ pub struct BenchmarkResult {
pub total_commits: usize,
pub analyzed_commits: usize,
pub total_entities_reviewed: usize,
pub graph_file_count: usize,
pub graph_entity_count: usize,
pub graph_list_files_ms: u64,
pub graph_build_ms: u64,
// Noise reduction
pub cosmetic_ratio: f64,
pub noise_reduction: f64,
Expand Down Expand Up @@ -76,7 +80,11 @@ pub fn run(args: BenchArgs) {
.map(|n| n.to_string_lossy().to_string())
.unwrap_or_else(|| repo.display().to_string());

eprintln!("inspect bench: analyzing {} (limit: {})", repo.display(), args.limit);
eprintln!(
"inspect bench: analyzing {} (limit: {})",
repo.display(),
args.limit
);

// Get commit SHAs
let output = Command::new("git")
Expand All @@ -101,6 +109,22 @@ pub fn run(args: BenchArgs) {

eprintln!("found {} commits", commits_info.len());

eprintln!("building reusable entity graph...");
let graph = match build_analysis_graph(&repo) {
Ok(graph) => graph,
Err(e) => {
eprintln!("error: failed to build entity graph: {}", e);
std::process::exit(1);
}
};
eprintln!(
"built graph: {} files, {} entities (list: {}ms, build: {}ms)",
graph.file_count(),
graph.total_graph_entities(),
graph.list_files_ms(),
graph.graph_build_ms()
);

let mut commit_benchmarks: Vec<CommitBenchmark> = Vec::new();
let mut total_entities = 0usize;
let mut total_cosmetic = 0usize;
Expand All @@ -125,7 +149,7 @@ pub fn run(args: BenchArgs) {
sha: sha.to_string(),
};

match analyze(&repo, scope) {
match analyze_with_graph(&repo, scope, &graph) {
Ok(result) => {
if result.entity_reviews.is_empty() {
continue;
Expand Down Expand Up @@ -283,6 +307,10 @@ pub fn run(args: BenchArgs) {
total_commits: commits_info.len(),
analyzed_commits: analyzed,
total_entities_reviewed: total_entities,
graph_file_count: graph.file_count(),
graph_entity_count: graph.total_graph_entities(),
graph_list_files_ms: graph.list_files_ms(),
graph_build_ms: graph.graph_build_ms(),
cosmetic_ratio,
noise_reduction,
avg_entities_per_file,
Expand Down
Loading
Loading