Files
rustytorch/crates/tooling/rtx-bench/examples/basic_benchmark.rs
T
2026-03-04 00:08:42 +00:00

68 lines
2.1 KiB
Rust

//! Basic benchmark example to demonstrate RTX benchmark functionality
use rtx_bench::{BenchmarkConfig, BenchmarkSuite};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize logging
tracing_subscriber::fmt::init();
println!("RTX Benchmark Suite Example");
println!("============================");
// Create benchmark configuration
let config = BenchmarkConfig::default()
.with_warmup_iterations(2)
.with_measurement_iterations(5)
.with_gpu_enabled(false)
.with_distributed_enabled(false);
println!("Configuration:");
println!(" Warmup iterations: {}", config.warmup_iterations);
println!(
" Measurement iterations: {}",
config.measurement_iterations
);
println!(" GPU enabled: {}", config.enable_gpu);
println!(" Distributed enabled: {}", config.enable_distributed);
// Create benchmark suite
let suite = BenchmarkSuite::new(config);
// Run core infrastructure benchmarks
println!("\nRunning core infrastructure benchmarks...");
let core_results = suite.run_core_infrastructure_benchmarks().await?;
println!("Core benchmarks completed:");
println!(" Suite: {}", core_results.suite_name);
println!(" Total benchmarks: {}", core_results.benchmarks.len());
println!(
" Duration: {:.2}s",
core_results.total_duration().as_secs_f64()
);
if !core_results.warnings.is_empty() {
println!(" Warnings: {}", core_results.warnings.len());
for warning in &core_results.warnings {
println!(" - {}", warning);
}
}
// Display benchmark results
if !core_results.benchmarks.is_empty() {
println!("\nBenchmark Results:");
for (name, stats) in &core_results.benchmarks {
println!(
" {}: {:.2}ms ± {:.2}ms (CV: {:.3})",
name,
stats.mean_ns / 1_000_000.0,
stats.std_dev_ns / 1_000_000.0,
stats.cv
);
}
}
println!("\nExample completed successfully!");
Ok(())
}