-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker_compare.go
51 lines (41 loc) · 1.47 KB
/
worker_compare.go
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
package main
import (
"errors"
"fmt"
"path/filepath"
"go.uber.org/zap"
"gonum.org/v1/plot/plotter"
)
func CompareTests(input CompareParams, testFiles ...string) error {
title := input.name() + "_" + input.info()
linesTps := make([]Line, len(testFiles))
linesLatency := make([]Line, len(testFiles))
for i, testFile := range testFiles {
rs, e := countResultsFile(testFile, input.SortTps, input.SortLatency)
if e != nil {
logger.Error("countResultsFile err", zap.String("testReport", testFile), zap.String("err", e.Error()))
return e
}
if input.To > len(rs.TPSes) {
input.To = len(rs.TPSes)
if input.From >= input.To {
return errors.New(fmt.Sprintf("wrong from, to range, from:%d, to:%d, max to:%d", from, to, input.To))
}
}
xysTPS := make(plotter.XYs, 0, input.To-input.From)
for j, v := range rs.TPSes[input.From:input.To] {
xysTPS = append(xysTPS, plotter.XY{X: float64(j + 1), Y: v})
}
linesTps[i] = Line{name: testFile, xys: xysTPS}
xysLatency := make(plotter.XYs, 0, input.To-input.From)
for j, v := range rs.LatencySummary.Latencies[input.From:input.To] {
xysLatency = append(xysLatency, plotter.XY{X: float64(j + 1), Y: v})
}
linesLatency[i] = Line{name: testFile, xys: xysLatency}
}
e := DrawLines(title, XLabel, TpsYLabel, filepath.Join(CompareTpsDir, title+PngSuffix), linesTps)
if e != nil {
return e
}
return DrawLines(title, XLabel, LatencyYLabel, filepath.Join(CompareLatencyDir, title+PngSuffix), linesLatency)
}