use std::collections::HashMap;
use std::time::{Duration, SystemTime};
use serde::{Deserialize, Serialize};
use super::benchmark_config::{BenchmarkSuiteConfig, ParameterValue};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BenchmarkMetadata {
pub timestamp: SystemTime,
pub total_duration: Duration,
pub config: BenchmarkSuiteConfig,
pub system_info: SystemInfo,
pub git_commit: Option<String>,
pub environment: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SystemInfo {
pub os: String,
pub architecture: String,
pub cpu_model: String,
pub cpu_cores: u32,
pub total_memory_mb: u64,
pub available_memory_mb: u64,
pub hostname: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TestFailure {
pub test_name: String,
pub category: String,
pub parameters: HashMap<String, ParameterValue>,
pub reason: FailureReason,
pub error_message: String,
pub stack_trace: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum FailureReason {
Timeout,
OutOfMemory,
RuntimeError,
CompilationError,
ValidationFailure,
InfrastructureError,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceStats {
pub cpu: CPUStats,
pub memory: MemoryStats,
pub disk_io: DiskIOStats,
pub network_io: Option<NetworkIOStats>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CPUStats {
pub avg_usage_percent: f64,
pub peak_usage_percent: f64,
pub user_time: Duration,
pub kernel_time: Duration,
pub context_switches: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemoryStats {
pub avg_usage_bytes: u64,
pub peak_usage_bytes: u64,
pub allocations: u64,
pub deallocations: u64,
pub page_faults: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiskIOStats {
pub bytes_read: u64,
pub bytes_written: u64,
pub read_ops: u64,
pub write_ops: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NetworkIOStats {
pub bytes_received: u64,
pub bytes_sent: u64,
pub packets_received: u64,
pub packets_sent: u64,
}
pub type BenchmarkResult<T> = Result<T, Box<TestFailure>>;