@@ -19,20 +19,62 @@ var fPace = flag.Bool("pace", true, "whether to pace the traffic according to th
19
19
var fSkip = flag .Uint ("skip" , 0 , "skip N records" )
20
20
21
21
func RenderTable (area * pterm.AreaPrinter , files []string , workers []FileWorker ) {
22
- tableData := pterm.TableData {{"file" , "parsed" , "processed" , "delayed" , "clients" }}
22
+ tableData := pterm.TableData {{"file" , "parsed" , "processed" , "delayed" , "clients" , "avg(us)" , "p50(us)" , "p75(us)" , "p90(us)" , "p99(us)" }}
23
23
for i := range workers {
24
+ workers [i ].latencyMu .Lock ()
25
+ avg := 0.0
26
+ if workers [i ].latencyCount > 0 {
27
+ avg = workers [i ].latencySum / float64 (workers [i ].latencyCount )
28
+ }
29
+ p50 := workers [i ].latencyDigest .Quantile (0.5 )
30
+ p75 := workers [i ].latencyDigest .Quantile (0.75 )
31
+ p90 := workers [i ].latencyDigest .Quantile (0.9 )
32
+ p99 := workers [i ].latencyDigest .Quantile (0.99 )
33
+ workers [i ].latencyMu .Unlock ()
24
34
tableData = append (tableData , []string {
25
35
files [i ],
26
36
fmt .Sprint (atomic .LoadUint64 (& workers [i ].parsed )),
27
37
fmt .Sprint (atomic .LoadUint64 (& workers [i ].processed )),
28
38
fmt .Sprint (atomic .LoadUint64 (& workers [i ].delayed )),
29
39
fmt .Sprint (atomic .LoadUint64 (& workers [i ].clients )),
40
+ fmt .Sprintf ("%.0f" , avg ),
41
+ fmt .Sprintf ("%.0f" , p50 ),
42
+ fmt .Sprintf ("%.0f" , p75 ),
43
+ fmt .Sprintf ("%.0f" , p90 ),
44
+ fmt .Sprintf ("%.0f" , p99 ),
30
45
})
31
46
}
32
47
content , _ := pterm .DefaultTable .WithHasHeader ().WithBoxed ().WithData (tableData ).Srender ()
33
48
area .Update (content )
34
49
}
35
50
51
+ // RenderPipelineRangesTable renders the latency digests for each pipeline range
52
+ func RenderPipelineRangesTable (area * pterm.AreaPrinter , files []string , workers []FileWorker ) {
53
+ tableData := pterm.TableData {{"file" , "Pipeline Range" , "p50(us)" , "p75(us)" , "p90(us)" , "p99(us)" }}
54
+ for i := range workers {
55
+ workers [i ].latencyMu .Lock ()
56
+ for _ , rng := range pipelineRanges {
57
+ if digest , ok := workers [i ].perRange [rng .label ]; ok {
58
+ p50 := digest .Quantile (0.5 )
59
+ p75 := digest .Quantile (0.75 )
60
+ p90 := digest .Quantile (0.9 )
61
+ p99 := digest .Quantile (0.99 )
62
+ tableData = append (tableData , []string {
63
+ files [i ],
64
+ rng .label ,
65
+ fmt .Sprintf ("%.0f" , p50 ),
66
+ fmt .Sprintf ("%.0f" , p75 ),
67
+ fmt .Sprintf ("%.0f" , p90 ),
68
+ fmt .Sprintf ("%.0f" , p99 ),
69
+ })
70
+ }
71
+ }
72
+ workers [i ].latencyMu .Unlock ()
73
+ }
74
+ content , _ := pterm .DefaultTable .WithHasHeader ().WithBoxed ().WithData (tableData ).Srender ()
75
+ area .Update (content )
76
+ }
77
+
36
78
func Run (files []string ) {
37
79
timeOffset := time .Now ().Add (500 * time .Millisecond ).Sub (DetermineBaseTime (files ))
38
80
fmt .Println ("Offset -> " , timeOffset )
@@ -64,6 +106,8 @@ func Run(files []string) {
64
106
}
65
107
66
108
RenderTable (area , files , workers ) // to show last stats
109
+ areaPipelineRanges , _ := pterm .DefaultArea .WithCenter ().Start ()
110
+ RenderPipelineRangesTable (areaPipelineRanges , files , workers ) // to render per pipeline-range latency digests
67
111
}
68
112
69
113
func Print (files []string ) {
0 commit comments