mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #4165 from heyitsanthony/benchmark-stddev
tools/benchmark: report standard deviation
This commit is contained in:
commit
383e11d528
@ -18,6 +18,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -37,6 +38,7 @@ type report struct {
|
|||||||
fastest float64
|
fastest float64
|
||||||
slowest float64
|
slowest float64
|
||||||
average float64
|
average float64
|
||||||
|
stddev float64
|
||||||
rps float64
|
rps float64
|
||||||
|
|
||||||
results chan result
|
results chan result
|
||||||
@ -91,6 +93,11 @@ func (r *report) finalize() {
|
|||||||
|
|
||||||
r.rps = float64(len(r.lats)) / r.total.Seconds()
|
r.rps = float64(len(r.lats)) / r.total.Seconds()
|
||||||
r.average = r.avgTotal / float64(len(r.lats))
|
r.average = r.avgTotal / float64(len(r.lats))
|
||||||
|
for i := range r.lats {
|
||||||
|
dev := r.lats[i] - r.average
|
||||||
|
r.stddev += dev * dev
|
||||||
|
}
|
||||||
|
r.stddev = math.Sqrt(r.stddev / float64(len(r.lats)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *report) print() {
|
func (r *report) print() {
|
||||||
@ -104,6 +111,7 @@ func (r *report) print() {
|
|||||||
fmt.Printf(" Slowest:\t%4.4f secs.\n", r.slowest)
|
fmt.Printf(" Slowest:\t%4.4f secs.\n", r.slowest)
|
||||||
fmt.Printf(" Fastest:\t%4.4f secs.\n", r.fastest)
|
fmt.Printf(" Fastest:\t%4.4f secs.\n", r.fastest)
|
||||||
fmt.Printf(" Average:\t%4.4f secs.\n", r.average)
|
fmt.Printf(" Average:\t%4.4f secs.\n", r.average)
|
||||||
|
fmt.Printf(" Stddev:\t%4.4f secs.\n", r.stddev)
|
||||||
fmt.Printf(" Requests/sec:\t%4.4f\n", r.rps)
|
fmt.Printf(" Requests/sec:\t%4.4f\n", r.rps)
|
||||||
r.printHistogram()
|
r.printHistogram()
|
||||||
r.printLatencies()
|
r.printLatencies()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user