更新时延计算

This commit is contained in:
nnbcccscdscdsc
2026-03-23 21:30:37 +08:00
parent 2dd33bf73e
commit 32e77df476
6 changed files with 178 additions and 35 deletions

View File

@@ -215,6 +215,7 @@ const summaryChartHTMLTemplate = `<!doctype html>
<div class="row-e2e">{{.EndToEnd}}</div>
</div>
<div class="row-meta">{{.Subtitle}}</div>
<div class="row-meta">{{.ApproxRTT}}</div>
<div class="bar">
{{range .Segments}}
<div class="segment" style="width: {{printf "%.4f" .WidthPercent}}%; background: {{.Color}}" title="{{.Label}}: {{.Value}}"></div>
@@ -262,6 +263,7 @@ type summaryChartRow struct {
Title string
Subtitle string
EndToEnd string
ApproxRTT string
MissingTimestamps string
Segments []summaryChartSegment
}
@@ -314,7 +316,7 @@ func buildSummaryChartPage(summaries []Summary) summaryChartPage {
Legend: []summaryChartLegendItem{
{Label: "A processing", Color: "var(--a-proc)"},
{Label: "A queue", Color: "var(--a-queue)"},
{Label: "Transport + B queue", Color: "var(--transport)"},
{Label: "A-B transport + propagation", Color: "var(--transport)"},
{Label: "B processing", Color: "var(--b-proc)"},
{Label: "Unknown / missing", Color: "var(--unknown)"},
},
@@ -357,8 +359,12 @@ func buildSummaryChartRow(summary Summary) summaryChartRow {
Title: buildSummaryChartTitle(summary),
Subtitle: buildSummaryChartSubtitle(summary),
EndToEnd: "End-to-end: n/a",
ApproxRTT: "Approx RTT: n/a",
MissingTimestamps: strings.Join(summary.MissingTimestamps, ", "),
}
if summary.ApproxRTTNS != nil && *summary.ApproxRTTNS > 0 {
row.ApproxRTT = fmt.Sprintf("Approx RTT: %s", formatLatencyNS(*summary.ApproxRTTNS))
}
if summary.EndToEndLatencyNS == nil || *summary.EndToEndLatencyNS <= 0 {
return row
@@ -370,7 +376,7 @@ func buildSummaryChartRow(summary Summary) summaryChartRow {
metrics := []summaryChartSegmentMetric{
{label: "A processing", value: summary.AProcessingLatencyNS, color: "var(--a-proc)"},
{label: "A queue", value: summary.AQueueLatencyNS, color: "var(--a-queue)"},
{label: "Transport + B queue", value: summary.ABTransportPropagationBQueueLatencyNS, color: "var(--transport)"},
{label: "A-B transport + propagation", value: summary.ABTransportPropagationNS, color: "var(--transport)"},
{label: "B processing", value: summary.BProcessingLatencyNS, color: "var(--b-proc)"},
}