()
| 388 | |
| 389 | #[test] |
| 390 | fn test_effectiveness_metrics() { |
| 391 | let manager = OptimizationManager::new(true); |
| 392 | |
| 393 | // Analyze a few queries to get stats |
| 394 | let result1 = manager.analyze_query("SELECT * FROM users WHERE id = 1").unwrap(); |
| 395 | let result2 = manager.analyze_query("INSERT INTO users (name) VALUES ('test')").unwrap(); |
| 396 | let result3 = manager.analyze_query("SELECT COUNT(*) FROM users").unwrap(); |
| 397 | |
| 398 | // Update fast path hits manually since we're not actually executing queries |
| 399 | { |
| 400 | let mut stats = manager.optimization_stats.write().unwrap(); |
| 401 | if result1.should_use_fast_path { |
| 402 | stats.fast_path_hits += 1; |
| 403 | } |
| 404 | if result2.should_use_fast_path { |
| 405 | stats.fast_path_hits += 1; |
| 406 | } |
| 407 | if result3.should_use_fast_path { |
| 408 | stats.fast_path_hits += 1; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | let effectiveness = manager.get_effectiveness_metrics(); |
| 413 | assert!(effectiveness.fast_path_rate >= 0.0); |
| 414 | assert!(effectiveness.avg_optimization_time_ms >= 0.0); |
| 415 | assert!(!effectiveness.pattern_distribution.is_empty()); |
| 416 | } |
| 417 | } |
nothing calls this directly
no test coverage detected