parent
2493a2391b
commit
eb455d6e43
|
@ -17,7 +17,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func bench(cephconn *cephconnection, osddevice Device, buff *[]byte, startbuff *[]byte, params *params,
|
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()
|
defer wg.Done()
|
||||||
threadresult := make(chan []time.Duration, params.threadsCount)
|
threadresult := make(chan []time.Duration, params.threadsCount)
|
||||||
var objectnames []string
|
var objectnames []string
|
||||||
|
@ -121,11 +121,13 @@ func bench(cephconn *cephconnection, osddevice Device, buff *[]byte, startbuff *
|
||||||
}
|
}
|
||||||
buffer.WriteString("\n\n")
|
buffer.WriteString("\n\n")
|
||||||
|
|
||||||
|
totalLats <- avgLatencies{latencytotal: latencytotal, len: int64(len(osdlatencies))}
|
||||||
|
|
||||||
latencytotal = latencytotal / int64(len(osdlatencies))
|
latencytotal = latencytotal / int64(len(osdlatencies))
|
||||||
// iops = 1s / latency
|
// iops = 1s / latency
|
||||||
iops := 1000000 / latencytotal * int64(params.threadsCount)
|
iops := 1000000 / latencytotal * int64(params.threadsCount)
|
||||||
// avg speed = iops * block size / 1 MB
|
// 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",
|
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)
|
iops, avgspeed, len(osdlatencies), uint64(len(osdlatencies))*params.blocksize/1024/1024)
|
||||||
switch {
|
switch {
|
||||||
|
@ -235,12 +237,16 @@ func main() {
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
results := make(chan string, len(osddevices)*int(params.threadsCount))
|
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 {
|
for _, osd := range osddevices {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
if params.parallel == true {
|
if params.parallel == true {
|
||||||
go bench(cephconn, osd, &buff, &startbuff, ¶ms, &wg, results)
|
go bench(cephconn, osd, &buff, &startbuff, ¶ms, &wg, results, totalLats)
|
||||||
} else {
|
} else {
|
||||||
bench(cephconn, osd, &buff, &startbuff, ¶ms, &wg, results)
|
bench(cephconn, osd, &buff, &startbuff, ¶ms, &wg, results, totalLats)
|
||||||
|
avgLats = append(avgLats, <-totalLats)
|
||||||
log.Println(<-results)
|
log.Println(<-results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,12 +256,38 @@ func main() {
|
||||||
go func() {
|
go func() {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
close(results)
|
close(results)
|
||||||
|
close(totalLats)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for message := range results {
|
for message := range results {
|
||||||
log.Println(message)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue