Skip to content

Commit

Permalink
Add segment average request time to csv (#237)
Browse files Browse the repository at this point in the history
Add average request time for every operation that ended in segment.
  • Loading branch information
klauspost authored Dec 14, 2022
1 parent 04ce94a commit 9c8fa84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Vet
- name: go vet
run: go vet ./...

- name: fmt
- name: go fmt
run: diff <(gofmt -d .) <(printf "")

- name: Lint
Expand Down
6 changes: 6 additions & 0 deletions pkg/bench/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Segment struct {
OpsEnded int `json:"ops_ended"`
Objects float64 `json:"objects"`
Errors int `json:"errors"`
ReqAvg float64 `json:"req_avg_ms"` // Average duration of operations ending in segment.
Start time.Time `json:"start"`
EndsBefore time.Time `json:"ends_before"`
}
Expand Down Expand Up @@ -189,6 +190,9 @@ func (o Operations) Segment(so SegmentOptions) Segments {
break
}
}
if s.OpsEnded > 0 {
s.ReqAvg /= float64(s.OpsEnded)
}
segments = append(segments, s)
segStart = segStart.Add(so.PerSegDuration)
}
Expand Down Expand Up @@ -234,6 +238,7 @@ func (s Segments) CSV(w io.Writer) error {
"mb_per_sec",
"ops_ended_per_sec",
"objs_per_sec",
"reqs_ended_avg_ms",
"start_time",
"end_time",
})
Expand Down Expand Up @@ -268,6 +273,7 @@ func (s Segment) CSV(w *csv.Writer, idx int) error {
fmt.Sprint(mib),
fmt.Sprint(ops),
fmt.Sprint(objs),
fmt.Sprint(s.ReqAvg),
fmt.Sprint(s.Start),
fmt.Sprint(s.EndsBefore),
})
Expand Down
2 changes: 2 additions & 0 deletions pkg/bench/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func (o Operation) Aggregate(s *Segment) (done bool) {
s.OpsEnded++
s.ObjsPerOp = o.ObjPerOp
s.Objects += float64(o.ObjPerOp)
s.ReqAvg += float64(o.End.Sub(o.Start)) / float64(time.Millisecond)
return
}
// Operation partially within segment.
Expand All @@ -253,6 +254,7 @@ func (o Operation) Aggregate(s *Segment) (done bool) {
s.Errors++
return
}
s.ReqAvg += float64(o.End.Sub(o.Start)) / float64(time.Millisecond)
}

opDur := o.End.Sub(o.Start)
Expand Down

0 comments on commit 9c8fa84

Please sign in to comment.