pub mod domain;
#[cfg(feature = "http")]
pub mod endpoint;
pub mod inference;
pub mod performance;
#[cfg(feature = "http")]
pub mod prometheus_exporter;
#[cfg(feature = "http")]
pub use endpoint::metrics_endpoint;
#[cfg(feature = "http")]
pub use endpoint::metrics_middleware;
pub use inference::InferenceCollector;
#[cfg(feature = "http")]
pub use prometheus_exporter::PrometheusCollector;
pub fn inbatch_dedup_ratio(total: usize, unique: usize) -> f64 {
if total == 0 || unique >= total {
return 0.0;
}
1.0 - (unique as f64 / total as f64)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_dedup_ratio_no_dup_is_zero() {
assert_eq!(inbatch_dedup_ratio(4, 4), 0.0);
assert_eq!(inbatch_dedup_ratio(1, 1), 0.0);
}
#[test]
fn test_dedup_ratio_all_dup() {
let r = inbatch_dedup_ratio(4, 1);
assert!((r - 0.75).abs() < 1e-12, "4 条全重复应为 (4-1)/4=0.75");
}
#[test]
fn test_dedup_ratio_empty_is_zero() {
assert_eq!(inbatch_dedup_ratio(0, 0), 0.0);
}
}