use super::*;
#[test]
fn test_showcase_runner_to_grid_native_without_gguf_with_ollama() {
let config = ShowcaseConfig::default();
let mut runner = ShowcaseRunner::new(config)
.with_model_info("TestModel", "0.5B", "Q4_K_M")
.with_gpu_info("Test GPU", 8.0);
let native_results = vec![BenchmarkResult::new(
128,
Duration::from_millis(180),
Duration::from_millis(5),
)];
runner.record_apr_native(BenchmarkStats::from_results(native_results));
let ollama_results = vec![BenchmarkResult::new(
128,
Duration::from_millis(400),
Duration::from_millis(50),
)];
runner.record_ollama(BenchmarkStats::from_results(ollama_results));
let grid = runner.to_grid();
let output = grid.render();
assert!(!output.is_empty());
}
#[test]
fn test_stats_to_measurement_without_gpu_metrics() {
let config = ShowcaseConfig::default();
let runner = ShowcaseRunner::new(config);
let results = vec![BenchmarkResult::new(
128,
Duration::from_millis(256),
Duration::from_millis(7),
)];
let stats = BenchmarkStats::from_results(results);
let mut runner_with_stats = ShowcaseRunner::new(ShowcaseConfig::default());
runner_with_stats.record_apr_gguf(stats.clone());
let grid = runner_with_stats.to_grid();
let output = grid.render();
assert!(!output.is_empty());
drop(runner);
}
#[test]
fn test_pmat_verification_to_report_point_41_fail() {
let config = ShowcaseConfig::default();
let mut runner = ShowcaseRunner::new(config);
let apr_results: Vec<BenchmarkResult> = (0..3)
.map(|_| BenchmarkResult::new(128, Duration::from_millis(2560), Duration::from_millis(50)))
.collect();
runner.record_apr_gguf(BenchmarkStats::from_results(apr_results));
let verification = PmatVerification::verify(&runner);
assert!(!verification.point_41_pass);
let report = verification.to_report();
assert!(report.contains("FAIL"));
}
#[test]
fn test_pmat_verification_to_report_point_42_fail() {
let config = ShowcaseConfig::default();
let mut runner = ShowcaseRunner::new(config);
let apr_results: Vec<BenchmarkResult> = (0..3)
.map(|_| BenchmarkResult::new(128, Duration::from_millis(4267), Duration::from_millis(100)))
.collect();
runner.record_apr_gguf(BenchmarkStats::from_results(apr_results));
let verification = PmatVerification::verify(&runner);
assert!(!verification.point_42_pass);
let report = verification.to_report();
assert!(report.contains("FAIL"));
}
#[test]
fn test_pmat_verification_to_report_point_49_fail() {
let config = ShowcaseConfig::default();
let mut runner = ShowcaseRunner::new(config);
let apr_results = vec![
BenchmarkResult::new(128, Duration::from_millis(100), Duration::from_millis(5)),
BenchmarkResult::new(128, Duration::from_millis(500), Duration::from_millis(50)),
BenchmarkResult::new(128, Duration::from_millis(200), Duration::from_millis(20)),
];
runner.record_apr_gguf(BenchmarkStats::from_results(apr_results));
let verification = PmatVerification::verify(&runner);
assert!(!verification.point_49_pass);
let report = verification.to_report();
assert!(report.contains("FAIL") || report.contains("Point 49"));
}
#[test]
fn test_pmat_verification_to_report_ollama_2x_pending() {
let config = ShowcaseConfig::default();
let mut runner = ShowcaseRunner::new(config);
let apr_results: Vec<BenchmarkResult> = (0..3)
.map(|_| BenchmarkResult::new(128, Duration::from_millis(320), Duration::from_millis(10)))
.collect();
runner.record_apr_gguf(BenchmarkStats::from_results(apr_results));
let verification = PmatVerification::verify(&runner);
assert!(!verification.ollama_2x_pass);
let report = verification.to_report();
assert!(report.contains("PENDING"));
}
#[test]
fn test_pmat_verification_to_report_overall_needs_work() {
let config = ShowcaseConfig::default();
let runner = ShowcaseRunner::new(config);
let verification = PmatVerification::verify(&runner);
assert!(!verification.all_pass);
let report = verification.to_report();
assert!(report.contains("NEEDS WORK"));
}
#[test]
fn test_stats_to_measurement_with_gpu_metrics_coverage() {
let config = ShowcaseConfig::default();
let mut runner = ShowcaseRunner::new(config)
.with_model_info("Model", "1B", "Q4_K")
.with_gpu_info("GPU", 8.0);
let results = vec![
BenchmarkResult::new(100, Duration::from_millis(200), Duration::from_millis(5))
.with_gpu_metrics(95.0, 8192.0),
BenchmarkResult::new(100, Duration::from_millis(195), Duration::from_millis(6))
.with_gpu_metrics(92.0, 8100.0),
];
runner.record_apr_gguf(BenchmarkStats::from_results(results));
let grid = runner.to_grid();
let output = grid.render();
assert!(!output.is_empty());
}
#[test]
fn test_showcase_runner_native_only_no_baseline_stats() {
let config = ShowcaseConfig::default();
let mut runner = ShowcaseRunner::new(config)
.with_model_info("Model", "1B", "Q4_K")
.with_gpu_info("GPU", 8.0);
let native_results = vec![BenchmarkResult::new(
100,
Duration::from_millis(150),
Duration::from_millis(4),
)];
runner.record_apr_native(BenchmarkStats::from_results(native_results));
let grid = runner.to_grid();
let output = grid.render();
assert!(!output.is_empty());
}