Print avg statistics after benchmark.

Fix avgspeed counting
master
Alexey Kostin 2019-03-04 17:42:36 +03:00
parent 2493a2391b
commit eb455d6e43
2 changed files with 42 additions and 5 deletions

View File

@ -17,7 +17,7 @@ import (
)
func bench(cephconn *cephconnection, osddevice Device, buff *[]byte, startbuff *[]byte, params *params,
wg *sync.WaitGroup, result chan string) {
wg *sync.WaitGroup, result chan string, totalLats chan avgLatencies) {
defer wg.Done()
threadresult := make(chan []time.Duration, params.threadsCount)
var objectnames []string
@ -121,11 +121,13 @@ func bench(cephconn *cephconnection, osddevice Device, buff *[]byte, startbuff *
}
buffer.WriteString("\n\n")
totalLats <- avgLatencies{latencytotal: latencytotal, len: int64(len(osdlatencies))}
latencytotal = latencytotal / int64(len(osdlatencies))
// iops = 1s / latency
iops := 1000000 / latencytotal * int64(params.threadsCount)
// avg speed = iops * block size / 1 MB
avgspeed := 1000000 / float64(latencytotal) * float64(params.blocksize) / 1024 / 1024 * float64(params.threadsCount)
avgspeed := float64(iops) * float64(params.blocksize) / 1024 / 1024
avgline := fmt.Sprintf("Avg iops: %-5v Avg speed: %.3f MB/s Total writes count: %-5v Total writes (MB): %-5v\n\n",
iops, avgspeed, len(osdlatencies), uint64(len(osdlatencies))*params.blocksize/1024/1024)
switch {
@ -235,12 +237,16 @@ func main() {
var wg sync.WaitGroup
results := make(chan string, len(osddevices)*int(params.threadsCount))
totalLats := make(chan avgLatencies, len(osddevices))
avgLats := []avgLatencies{}
log.Println("Benchmark started")
for _, osd := range osddevices {
wg.Add(1)
if params.parallel == true {
go bench(cephconn, osd, &buff, &startbuff, &params, &wg, results)
go bench(cephconn, osd, &buff, &startbuff, &params, &wg, results, totalLats)
} else {
bench(cephconn, osd, &buff, &startbuff, &params, &wg, results)
bench(cephconn, osd, &buff, &startbuff, &params, &wg, results, totalLats)
avgLats = append(avgLats, <-totalLats)
log.Println(<-results)
}
@ -250,12 +256,38 @@ func main() {
go func() {
wg.Wait()
close(results)
close(totalLats)
}()
for message := range results {
log.Println(message)
}
for lat := range totalLats {
avgLats = append(avgLats, lat)
}
}
sumLat := int64(0)
countLat := int64(0)
for _, avgLat := range avgLats {
sumLat += avgLat.latencytotal
countLat += avgLat.len
}
//count avg statistics
sumLat = sumLat / int64(countLat)
avgIops := 1000000 / sumLat * int64(params.threadsCount)
sumIops := 1000000 / sumLat * int64(params.threadsCount) * int64(len(osddevices))
avgSpeed := float64(avgIops) * float64(params.blocksize) / 1024 / 1024
sumSpeed := float64(sumIops) * float64(params.blocksize) / 1024 / 1024
color.Set(color.FgHiYellow)
defer color.Unset()
fmt.Printf("Summary avg iops per osd:%5d Summary avg speed per osd: %.3f MB/s\n"+
"Total writes count:%11d Total writes (MB): %v\n",
avgIops, avgSpeed, countLat, uint64(countLat)*params.blocksize/1024/1024)
if params.parallel {
fmt.Printf("Summary avg iops:%13d Summary avg speed: %.3f MB/s\n", sumIops, sumSpeed)
}
}

View File

@ -386,3 +386,8 @@ type OsdMap struct {
Up []uint64 `json:"up"`
UpPrimary int64 `json:"up_primary"`
}
type avgLatencies struct {
latencytotal int64
len int64
}