1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! Statistical analysis and comparison structures for benchmark results.
//!
//! This module provides structures for cross-implementation performance comparisons,
//! statistical significance testing, performance rankings, and correlation analysis
//! to enable comprehensive benchmark result interpretation and insights.
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
/// Comparison between implementations
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImplementationComparison {
/// Implementation A
pub impl_a: String,
/// Implementation B
pub impl_b: String,
/// Performance ratio (A/B)
pub performance_ratio: f64,
/// Statistical significance of difference
pub significance: StatisticalSignificance,
/// Category-wise comparisons
pub category_comparisons: HashMap<String, CategoryComparison>,
}
/// Statistical significance information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatisticalSignificance {
/// p-value from statistical test
pub p_value: f64,
/// Whether difference is statistically significant
pub is_significant: bool,
/// Type of statistical test used
pub test_type: String,
/// Effect size measure
pub effect_size: f64,
}
/// Category-specific comparison
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CategoryComparison {
/// Category name
pub category: String,
/// Performance difference (percentage)
pub performance_difference: f64,
/// Winner of this category
pub winner: String,
/// Confidence in the comparison
pub confidence: f64,
}
/// Statistical summary across all implementations
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatisticalSummary {
/// Overall performance rankings
pub performance_rankings: Vec<PerformanceRanking>,
/// Category leaders
pub category_leaders: HashMap<String, String>,
/// Performance distribution statistics
pub distribution_stats: DistributionStats,
/// Correlation analysis
pub correlation_analysis: CorrelationAnalysis,
}
/// Performance ranking entry
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PerformanceRanking {
/// Implementation name
pub implementation: String,
/// Overall rank (1 = best)
pub rank: u32,
/// Overall performance score
pub score: f64,
/// Wins by category
pub category_wins: u32,
/// Confidence interval for ranking
pub ranking_confidence: f64,
}
/// Distribution statistics
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DistributionStats {
/// Performance distribution shape
pub distribution_shape: DistributionShape,
/// Variance in performance across implementations
pub performance_variance: f64,
/// Outlier implementations
pub outliers: Vec<String>,
}
/// Shape of performance distribution
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DistributionShape {
/// Normal (Gaussian) distribution
Normal,
/// Skewed distribution
Skewed,
/// Bimodal distribution with two peaks
Bimodal,
/// Uniform distribution
Uniform,
/// Unknown or unclassified distribution shape
Unknown,
}
/// Correlation analysis between different metrics
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CorrelationAnalysis {
/// Correlation between categories
pub category_correlations: HashMap<String, HashMap<String, f64>>,
/// Memory vs speed correlation
pub memory_speed_correlation: f64,
/// Implementation feature correlations
pub feature_correlations: HashMap<String, f64>,
}