50
50
regexp .MustCompile (`average= *(\d+\.?\d*) μs$` ),
51
51
regexp .MustCompile (`stddev= *(\d+\.?\d*) μs$` ),
52
52
}
53
+ WrkStatsRegexps = [2 ]* regexp.Regexp {
54
+ regexp .MustCompile (`Requests/sec: *(\d+\.?\d*)$` ),
55
+ regexp .MustCompile (`Transfer/sec: *(\d+\.?\d*)([K|M|G|T|P])B$` ),
56
+ }
57
+ unitScale = map [string ]float64 {
58
+ "K" : 1.0 ,
59
+ "M" : 1024.0 ,
60
+ "G" : 1024.0 * 1024.0 ,
61
+ "T" : 1024.0 * 1024.0 * 1024.0 ,
62
+ "P" : 1024.0 * 1024.0 * 1024.0 * 1024.0 ,
63
+ }
53
64
54
65
NoDeleteContainersOnExit = false
55
66
username string
@@ -77,6 +88,7 @@ type RunningApp struct {
77
88
CoresStats []CoresInfo
78
89
abs * ApacheBenchmarkStats
79
90
lats * LatencyStats
91
+ wrks * WrkBenchmarkStats
80
92
Logger * Logger
81
93
benchStartTime time.Time
82
94
benchEndTime time.Time
@@ -138,9 +150,10 @@ func (app *RunningApp) testRoutine(report chan<- TestReport, done <-chan struct{
138
150
app .Status = TestRunning
139
151
if app .config .Type == TestAppApacheBenchmark {
140
152
app .abs = & ApacheBenchmarkStats {}
141
- }
142
- if app .config .Type == TestAppLatency {
153
+ } else if app .config .Type == TestAppLatency {
143
154
app .lats = & LatencyStats {}
155
+ } else if app .config .Type == TestAppWrkBenchmark {
156
+ app .wrks = & WrkBenchmarkStats {}
144
157
}
145
158
146
159
scanner := bufio .NewScanner (logs )
@@ -156,6 +169,23 @@ func (app *RunningApp) testRoutine(report chan<- TestReport, done <-chan struct{
156
169
} else if TestFailedRegexp .FindStringIndex (str ) != nil {
157
170
status = TestReportedFailed
158
171
} else {
172
+ fillstats := func (stats []float64 , rexps []* regexp.Regexp ) {
173
+ for iii := range rexps {
174
+ matches := rexps [iii ].FindStringSubmatch (str )
175
+ if len (matches ) >= 2 {
176
+ var value float64
177
+ n , err := fmt .Sscanf (matches [1 ], "%f" , & value )
178
+ if err == nil && n == 1 {
179
+ stats [iii ] = value
180
+ if len (matches ) == 3 {
181
+ // Next match is unit letter
182
+ stats [iii ] *= unitScale [matches [2 ]]
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
+
159
189
// Scan for strings specific to test application type
160
190
if app .config .Type == TestAppGo {
161
191
// Get cores number information for NFF-Go application
@@ -175,28 +205,13 @@ func (app *RunningApp) testRoutine(report chan<- TestReport, done <-chan struct{
175
205
}
176
206
} else if app .config .Type == TestAppApacheBenchmark {
177
207
// Get Apache Benchmark output
178
- for iii := range ABStatsRegexps {
179
- matches := ABStatsRegexps [iii ].FindStringSubmatch (str )
180
- if len (matches ) == 2 {
181
- var value float32
182
- n , err := fmt .Sscanf (matches [1 ], "%f" , & value )
183
- if err == nil && n == 1 {
184
- app .abs .Stats [iii ] = value
185
- }
186
- }
187
- }
208
+ fillstats (app .abs .Stats [:], ABStatsRegexps [:])
188
209
} else if app .config .Type == TestAppLatency {
189
210
// Get Latency perf test output
190
- for iii := range LatStatsRegexps {
191
- matches := LatStatsRegexps [iii ].FindStringSubmatch (str )
192
- if len (matches ) == 2 {
193
- var value float32
194
- n , err := fmt .Sscanf (matches [1 ], "%f" , & value )
195
- if err == nil && n == 1 {
196
- app .lats .Stats [iii ] = value
197
- }
198
- }
199
- }
211
+ fillstats (app .lats .Stats [:], LatStatsRegexps [:])
212
+ } else if app .config .Type == TestAppWrkBenchmark {
213
+ // Get Wrk Benchmark output
214
+ fillstats (app .wrks .Stats [:], WrkStatsRegexps [:])
200
215
}
201
216
}
202
217
0 commit comments