Skip to content

Commit 8afc7d8

Browse files
authored
Add new CLI argument (#13)
* Add new CLI argument Add support for `-ab-time-per-request` CLI argument, which will show Apache Benchmark style `Time per request` metrics. Closes: #12 * Fix Makrdown
1 parent d74fc6b commit 8afc7d8

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.1] - 2022-02-01
9+
10+
### Added
11+
12+
- New CLI arg `--ab-time-per-request` show Apache Benchmark style time per request
13+
metric, which is hidden by default. Fixes #12.
14+
15+
### Removed
16+
17+
- `OverallRequestTimeSeconds` has been removed from the JSON report to avoid confusion.
18+
Related to #12.
19+
820
## [0.4.0] - 2021-12-07
921

1022
### Added

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ Completed requests: 1517
5757
Succeeded requests: 1517
5858
Failed requests: 0
5959
Requests per second: 50.57 (mean, across all concurrent requests)
60-
Request duration 19.78ms (mean, across all concurrent requests)
6160
Transfer rate (HTTP Message Body) 319 kB/s sent (mean)
6261
253 kB/s sent (mean, across all concurrent requests)
6362
637 kB/s received (mean)
@@ -104,7 +103,6 @@ Completed requests: 222
104103
Succeeded requests: 222
105104
Failed requests: 0
106105
Requests per second: 20.25 (mean, across all concurrent requests)
107-
Request duration 49.37ms (mean, across all concurrent requests)
108106
Transfer rate (HTTP Message Body) 279 kB/s sent (mean)
109107
101 kB/s sent (mean, across all concurrent requests)
110108
558 kB/s received (mean)
@@ -234,6 +232,16 @@ you need to do this:
234232

235233
See the [open issues](https://github.com/wayfair-incubator/minigun/issues) for a list of proposed features (and known issues).
236234

235+
## Release Management
236+
237+
- Push changes via Github Pull Requests, review and merge them.
238+
- Change the version constant in the `main.go` file.
239+
- Add all changes introduced since the last release to the `CHANGELOG.md` file.
240+
- When the new release is ready, [draft a new release](https://github.com/wayfair-incubator/minigun/releases/new):
241+
- Make sure to specify a new tag, make sure to follow [SemVer spec](https://semver.org/spec/v2.0.0.html).
242+
- Publish the new release.
243+
- All artifacts should be published automatically shortly after the new release is published.
244+
237245
## Contributing
238246

239247
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. For detailed contributing guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.md)

docs/report-help.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ minigun -fire-target http://kube-echo-perf-test.test.cluster.local/echo/1 \
99
-random-body-size 1KB \
1010
-fire-rate 10 \
1111
-workers 5 \
12-
-fire-duration 1m
12+
-fire-duration 1m \
13+
-ab-time-per-request
1314
```
1415

1516
Result:
@@ -29,7 +30,8 @@ Completed requests: 599
2930
Succeeded requests: 599
3031
Failed requests: 0
3132
Requests per second: 9.98 (mean, across all concurrent requests)
32-
Request duration 100.17ms (mean, across all concurrent requests)
33+
Time per request 1.81ms (mean)
34+
Time per request 100.17ms (mean, across all concurrent requests)
3335
Transfer rate (HTTP Message Body) 552 kB/s sent (mean)
3436
10 kB/s sent (mean, across all concurrent requests)
3537
552 kB/s received (mean)
@@ -56,9 +58,9 @@ of per worker metrics**.
5658

5759
So in the example above we're running 5 workers with desired request rate 10 reqs/s:
5860

59-
- `Full request duration 1.81ms (MEAN)` - every worker calculates exact time it takes
61+
- `Time per request 1.81ms (mean)` - every worker calculates exact time it takes
6062
to process the HTTP request. And this is the average of all the workers' metrics.
61-
- `Request duration 100.17ms (mean, across all concurrent requests)` - we're running
63+
- `Time per request 100.17ms (mean, across all concurrent requests)` - we're running
6264
10 requests per second from 5 workers, and since every worker can complete this request
6365
in `~1.81ms`, then we're not constrained by the app performance and can do 10 reqs/s
6466
exactly. Simple math shows that expected request time is `1 second / 10 requests`

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
)
3636

3737
// Constants and vars
38-
const version = "0.4.0"
38+
const version = "0.4.1"
3939
const workersCannelSize = 1024
4040
const errorBadHTTPCode = "Bad HTTP status code"
4141

@@ -59,6 +59,8 @@ type appConfig struct {
5959
instance string
6060
name string
6161

62+
abTimePerRequest bool
63+
6264
pushGateway string
6365
pushInterval time.Duration
6466

@@ -635,6 +637,8 @@ func main() {
635637
flag.StringVar(&config.report, "report", "text", "Report format. One of: 'text', 'table', 'json'")
636638
flag.BoolVar(&config.prettyJson, "pretty-json", false, "Pretty print JSON report with indents")
637639

640+
flag.BoolVar(&config.abTimePerRequest, "ab-time-per-request", false, "Show Apache Benchmark style time per request metric")
641+
638642
flag.StringVar(&config.name, "name", "default", "Benchmark run name. It will be used as 'name' label for metrics. Can be used for grouping all instances.")
639643
flag.StringVar(&config.instance, "instance", "", "Benchmark instance name. It will be used as 'instance' label for metrics. Default to hostname.")
640644
flag.StringVar(&config.pushGateway, "push-gateway", "", "Prometheus Pushgateway URL")

report.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type appReport struct {
3030
RequestsFailed float64 `json:"RequestsFailed"`
3131

3232
OverallRequestsRate float64 `json:"OverallRequestsRate"`
33-
OverallRequestTimeSeconds float64 `json:"OverallRequestTimeSeconds"`
3433
OverallSentBytesPerSecond float64 `json:"OverallSentBytesPerSecond"`
3534
OverallReceivedBytesPerSecond float64 `json:"OverallReceivedBytesPerSecond"`
3635

@@ -99,9 +98,6 @@ func collectReport(config appConfig, duration float64) appReport {
9998

10099
if requests, err := getCounter(config.metrics.requestsSendCount, config.metrics.labelValues...); err == nil {
101100
report.OverallRequestsRate = requests / duration
102-
103-
// Request time over all, cross all the concurency workers
104-
report.OverallRequestTimeSeconds = duration / float64(requests)
105101
}
106102

107103
// Time per request and transfer rates
@@ -272,9 +268,15 @@ func reportTextOld(config appConfig, duration float64) string {
272268
rate := requests / duration
273269
outMatrix = append(outMatrix, printRow{"Requests per second:", fmt.Sprintf("%.2f (mean, across all concurrent requests)", rate)})
274270

275-
// Request time over all, cross all the concurency workers
276-
overallRequestTime := humanizeDurationSeconds(duration / float64(requests))
277-
outMatrix = append(outMatrix, printRow{"Request duration", fmt.Sprintf("%v (mean, across all concurrent requests)", overallRequestTime)})
271+
if config.abTimePerRequest {
272+
// Mean request time
273+
if _, _, mean, _, err := getSummaryValues(registry, "minigun_requests_duration_seconds", config.metrics.labels); err == nil {
274+
outMatrix = append(outMatrix, printRow{"Time per request", fmt.Sprintf("%v (mean)", humanizeDurationSeconds(mean))})
275+
}
276+
// Request time over all, cross all the concurency workers
277+
overallRequestTime := humanizeDurationSeconds(duration / float64(requests))
278+
outMatrix = append(outMatrix, printRow{"Time per request", fmt.Sprintf("%v (mean, across all concurrent requests)", overallRequestTime)})
279+
}
278280
}
279281

280282
// Time per request and transfer rates

0 commit comments

Comments
 (0)