11use anyhow:: Result ;
22use code_guardian_core:: {
3- DetectorFactory , DetectorProfile , OptimizedScanner , Scanner , StreamingScanner ,
4- BenchmarkSuite , BenchmarkConfigurations , PerformanceAnalyzer ,
3+ BenchmarkConfigurations , BenchmarkSuite , DetectorFactory , DetectorProfile , OptimizedScanner ,
4+ PerformanceAnalyzer , Scanner , StreamingScanner ,
55} ;
66use std:: path:: Path ;
77use std:: time:: Instant ;
@@ -122,6 +122,7 @@ pub fn run_benchmark(path: &Path) -> Result<()> {
122122}
123123
124124/// Run comprehensive benchmark suite
125+ #[ allow( dead_code) ]
125126pub fn run_comprehensive_benchmark ( path : & Path , suite_type : & str ) -> Result < ( ) > {
126127 println ! ( "🚀 Code-Guardian Comprehensive Benchmark" ) ;
127128 println ! ( "=========================================\n " ) ;
@@ -144,14 +145,15 @@ pub fn run_comprehensive_benchmark(path: &Path, suite_type: &str) -> Result<()>
144145 } ;
145146
146147 suite. run_benchmarks ( path) ?;
147-
148+
148149 // Generate detailed report
149150 generate_benchmark_report ( & suite) ?;
150-
151+
151152 Ok ( ( ) )
152153}
153154
154155/// Run all benchmark suites
156+ #[ allow( dead_code) ]
155157pub fn run_all_benchmark_suites ( path : & Path ) -> Result < ( ) > {
156158 println ! ( "🏃♂️ Running All Benchmark Suites" ) ;
157159 println ! ( "==================================\n " ) ;
@@ -160,7 +162,10 @@ pub fn run_all_benchmark_suites(path: &Path) -> Result<()> {
160162 ( "Small Project" , BenchmarkConfigurations :: small_project( ) ) ,
161163 ( "Medium Project" , BenchmarkConfigurations :: medium_project( ) ) ,
162164 ( "Large Project" , BenchmarkConfigurations :: large_project( ) ) ,
163- ( "Regression Detection" , BenchmarkConfigurations :: regression_detection( ) ) ,
165+ (
166+ "Regression Detection" ,
167+ BenchmarkConfigurations :: regression_detection( ) ,
168+ ) ,
164169 ] ;
165170
166171 let mut all_results = Vec :: new ( ) ;
@@ -170,7 +175,7 @@ pub fn run_all_benchmark_suites(path: &Path) -> Result<()> {
170175 for ( name, mut suite) in suites {
171176 println ! ( "🔄 Running {} Suite..." , name) ;
172177 suite. run_benchmarks ( path) ?;
173-
178+
174179 total_passed += suite. summary . passed_tests ;
175180 total_tests += suite. summary . total_tests ;
176181 all_results. push ( ( name, suite) ) ;
@@ -183,7 +188,7 @@ pub fn run_all_benchmark_suites(path: &Path) -> Result<()> {
183188 println ! ( "Total Tests: {}" , total_tests) ;
184189 println ! ( "Total Passed: ✅ {}" , total_passed) ;
185190 println ! ( "Total Failed: ❌ {}" , total_tests - total_passed) ;
186-
191+
187192 let success_rate = ( total_passed as f64 / total_tests as f64 ) * 100.0 ;
188193 println ! ( "Success Rate: {:.1}%" , success_rate) ;
189194
@@ -199,12 +204,13 @@ pub fn run_all_benchmark_suites(path: &Path) -> Result<()> {
199204}
200205
201206/// Run performance analysis with detailed metrics
207+ #[ allow( dead_code) ]
202208pub fn run_performance_analysis ( path : & Path ) -> Result < ( ) > {
203209 println ! ( "🔍 Performance Analysis" ) ;
204210 println ! ( "======================\n " ) ;
205211
206212 let mut analyzer = PerformanceAnalyzer :: new ( ) ;
207-
213+
208214 analyzer. analyze_performance ( || {
209215 // Run a comprehensive scan for analysis
210216 let scanner = OptimizedScanner :: new ( DetectorProfile :: Comprehensive . get_detectors ( ) )
@@ -224,13 +230,17 @@ pub fn run_performance_analysis(path: &Path) -> Result<()> {
224230}
225231
226232/// Generate comprehensive benchmark report
233+ #[ allow( dead_code) ]
227234fn generate_benchmark_report ( suite : & BenchmarkSuite ) -> Result < ( ) > {
228235 println ! ( "\n 📊 Detailed Benchmark Report" ) ;
229236 println ! ( "============================" ) ;
230-
237+
231238 println ! ( "Suite: {}" , suite. name) ;
232- println ! ( "Performance Score: {:.1}/100" , suite. summary. performance_score) ;
233-
239+ println ! (
240+ "Performance Score: {:.1}/100" ,
241+ suite. summary. performance_score
242+ ) ;
243+
234244 if !suite. results . is_empty ( ) {
235245 println ! ( "\n 📈 Individual Test Results:" ) ;
236246 for result in & suite. results {
@@ -257,40 +267,45 @@ fn generate_benchmark_report(suite: &BenchmarkSuite) -> Result<()> {
257267}
258268
259269/// Save benchmark report to file
270+ #[ allow( dead_code) ]
260271fn save_benchmark_report ( suite : & BenchmarkSuite ) -> Result < ( ) > {
261272 use std:: fs;
262273 use std:: path:: PathBuf ;
263-
274+
264275 let timestamp = chrono:: Utc :: now ( ) . format ( "%Y%m%d_%H%M%S" ) ;
265- let filename = format ! ( "benchmark_report_{}_{}.json" ,
266- suite. name. replace( " " , "_" ) . to_lowercase( ) , timestamp) ;
267-
276+ let filename = format ! (
277+ "benchmark_report_{}_{}.json" ,
278+ suite. name. replace( " " , "_" ) . to_lowercase( ) ,
279+ timestamp
280+ ) ;
281+
268282 let reports_dir = PathBuf :: from ( "reports" ) ;
269283 fs:: create_dir_all ( & reports_dir) ?;
270-
284+
271285 let report_path = reports_dir. join ( filename) ;
272286 let json_report = serde_json:: to_string_pretty ( suite) ?;
273287 fs:: write ( & report_path, json_report) ?;
274-
288+
275289 println ! ( "\n 📄 Report saved to: {}" , report_path. display( ) ) ;
276290 Ok ( ( ) )
277291}
278292
279293/// Save performance analysis to file
280- fn save_performance_analysis ( analyzer : & PerformanceAnalyzer , path : & Path ) -> Result < ( ) > {
294+ #[ allow( dead_code) ]
295+ fn save_performance_analysis ( analyzer : & PerformanceAnalyzer , _path : & Path ) -> Result < ( ) > {
281296 use std:: fs;
282297 use std:: path:: PathBuf ;
283-
298+
284299 let timestamp = chrono:: Utc :: now ( ) . format ( "%Y%m%d_%H%M%S" ) ;
285300 let filename = format ! ( "performance_analysis_{}.json" , timestamp) ;
286-
301+
287302 let reports_dir = PathBuf :: from ( "reports" ) ;
288303 fs:: create_dir_all ( & reports_dir) ?;
289-
304+
290305 let report_path = reports_dir. join ( filename) ;
291306 let json_analysis = serde_json:: to_string_pretty ( analyzer) ?;
292307 fs:: write ( & report_path, json_analysis) ?;
293-
308+
294309 println ! ( "\n 📄 Analysis saved to: {}" , report_path. display( ) ) ;
295310 Ok ( ( ) )
296311}
0 commit comments