Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed May 12, 2024
1 parent bf4da36 commit ee11ab9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions disktest/disktest.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func ddTest1(path, deviceName, blockFile, blockName, blockCount, bs string) stri
defer os.Remove(path + blockFile)
if err == nil {
result += fmt.Sprintf("%-10s", strings.TrimSpace(deviceName)) + " " + fmt.Sprintf("%-15s", blockName) + " "
result += parseResultDD(tempText)
result += parseResultDD(tempText, blockCount)
}
// 读取测试
// dd if=/tmp/100MB.test of=/dev/null bs=4k count=25600 oflag=direct
Expand All @@ -59,7 +59,7 @@ func ddTest1(path, deviceName, blockFile, blockName, blockCount, bs string) stri
tempText, _ = execDDTest(path+blockFile, path+"/read"+blockFile, bs, blockCount)
defer os.Remove(path + "/read" + blockFile)
}
result += parseResultDD(tempText)
result += parseResultDD(tempText, blockCount)
result += "\n"
return result
}
Expand All @@ -80,7 +80,7 @@ func ddTest2(blockFile, blockName, blockCount, bs string) string {
testFilePath = "/root/"
result += fmt.Sprintf("%-10s", "/root") + " " + fmt.Sprintf("%-15s", blockName) + " "
}
result += parseResultDD(tempText)
result += parseResultDD(tempText, blockCount)
// 读取测试
tempText, err = execDDTest("/root/"+blockFile, "/dev/null", bs, blockCount)
defer os.Remove("/root/" + blockFile)
Expand All @@ -89,7 +89,7 @@ func ddTest2(blockFile, blockName, blockCount, bs string) string {
defer os.Remove(testFilePath + blockFile)
defer os.Remove("/tmp/read" + blockFile)
}
result += parseResultDD(tempText)
result += parseResultDD(tempText, blockCount)
result += "\n"
return result
}
Expand Down
8 changes: 4 additions & 4 deletions disktest/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func isWritableMountpoint(path string) bool {
}

// parseResultDD 提取dd测试的结果
func parseResultDD(tempText string) string {
func parseResultDD(tempText, blockCount string) string {
var result string
tp1 := strings.Split(tempText, "\n")
var records, usageTime float64
records, _ = strconv.ParseFloat(strings.Split(strings.TrimSpace(tp1[0]), "+")[0], 64)
records, _ = strconv.ParseFloat(blockCount, 64)
for _, t := range tp1 {
if strings.Contains(t, "bytes") {
// t 为 104857600 bytes (105 MB, 100 MiB) copied, 4.67162 s, 22.4 MB/s
Expand Down Expand Up @@ -111,8 +111,8 @@ func formatIOPS(raw interface{}, rawType string) string {
} else {
return ""
}
// Check if IOPS speed > 1k
if iops >= 1000 {
// Check if IOPS speed > 10k
if iops >= 10000 {
// Divide the raw result by 1k
result := float64(iops) / 1000.0
// Shorten the formatted result to one decimal place (i.e. x.x)
Expand Down

0 comments on commit ee11ab9

Please sign in to comment.