Skip to content

Commit 90b655a

Browse files
committed
feat(bench): add p95, p99, and stddev to summary table, show input size in header
Enhanced the summary table to provide more latency statistics at a glance: Changes: - Added p95, p99, and Stddev columns to summary table after Avg/Path - Removed Input Size column from table body - Updated header to show input size: "📊 SUMMARY - Performance at Largest Input Size (10K)" - Formatted size in header using format_size() for consistency (100, 10K, 1M) Summary table now shows: - Template name - Avg/Path (average time per path) - p95 (95th percentile latency) - p99 (99th percentile latency) - Stddev (standard deviation) - Throughput (paths/second) This provides a comprehensive performance overview without needing to check individual template details.
1 parent ea6ce98 commit 90b655a

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/bin/bench_throughput.rs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -649,25 +649,35 @@ fn print_statistics_explanation(sample_count: usize) {
649649
}
650650

651651
fn print_summary(all_results: &[(&str, Vec<BenchmarkResult>)]) {
652-
print_header("📊 SUMMARY - Performance at Largest Input Size");
652+
// Get the largest input size for the header
653+
let largest_size = all_results
654+
.iter()
655+
.filter_map(|(_, results)| results.last().map(|r| r.input_size))
656+
.max()
657+
.unwrap_or(0);
658+
659+
let header_text = format!("📊 SUMMARY - Performance at Largest Input Size ({})", format_size(largest_size));
660+
print_header(&header_text);
653661

654-
// Collect results with throughput for sorting
655-
let mut summary_data: Vec<(&str, usize, Duration, f64)> = all_results
662+
// Collect results with latency stats for sorting
663+
let mut summary_data: Vec<(&str, Duration, Duration, Duration, f64, f64)> = all_results
656664
.iter()
657665
.filter_map(|(name, results)| {
658666
results.last().map(|last| {
659667
(
660668
*name,
661-
last.input_size,
662669
last.avg_time_per_path,
670+
last.latency_stats.p95,
671+
last.latency_stats.p99,
672+
last.latency_stats.stddev,
663673
last.throughput_paths_per_sec,
664674
)
665675
})
666676
})
667677
.collect();
668678

669679
// Sort by throughput (highest first)
670-
summary_data.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap());
680+
summary_data.sort_by(|a, b| b.5.partial_cmp(&a.5).unwrap());
671681

672682
// Create summary table with comfy-table
673683
let mut table = Table::new();
@@ -678,18 +688,24 @@ fn print_summary(all_results: &[(&str, Vec<BenchmarkResult>)]) {
678688
Cell::new("Template")
679689
.add_attribute(TableAttribute::Bold)
680690
.fg(TableColor::Yellow),
681-
Cell::new("Input Size")
691+
Cell::new("Avg/Path")
682692
.add_attribute(TableAttribute::Bold)
683693
.fg(TableColor::Yellow),
684-
Cell::new("Avg/Path")
694+
Cell::new("p95")
695+
.add_attribute(TableAttribute::Bold)
696+
.fg(TableColor::Yellow),
697+
Cell::new("p99")
698+
.add_attribute(TableAttribute::Bold)
699+
.fg(TableColor::Yellow),
700+
Cell::new("Stddev")
685701
.add_attribute(TableAttribute::Bold)
686702
.fg(TableColor::Yellow),
687703
Cell::new("Throughput")
688704
.add_attribute(TableAttribute::Bold)
689705
.fg(TableColor::Yellow),
690706
]);
691707

692-
for (idx, (template_name, input_size, avg_time, throughput)) in summary_data.iter().enumerate()
708+
for (idx, (template_name, avg_time, p95, p99, stddev, throughput)) in summary_data.iter().enumerate()
693709
{
694710
// Highlight fastest (green) and slowest (yellow)
695711
let color = if idx == 0 {
@@ -702,8 +718,10 @@ fn print_summary(all_results: &[(&str, Vec<BenchmarkResult>)]) {
702718

703719
table.add_row(vec![
704720
Cell::new(template_name).fg(color),
705-
Cell::new(format_size(*input_size)).fg(color),
706721
Cell::new(format_duration(*avg_time)).fg(color),
722+
Cell::new(format_duration(*p95)).fg(color),
723+
Cell::new(format_duration(*p99)).fg(color),
724+
Cell::new(format_duration(Duration::from_nanos(*stddev as u64))).fg(color),
707725
Cell::new(format_throughput(*throughput)).fg(color),
708726
]);
709727
}

0 commit comments

Comments
 (0)