对硬盘写入速度格式化

This commit is contained in:
GoEdgeLab
2023-08-02 12:21:47 +08:00
parent 57c5f0cc15
commit cc763de221
2 changed files with 3 additions and 1 deletions

View File

@@ -436,7 +436,7 @@ func main() {
if err != nil {
fmt.Println("[ERROR]" + err.Error())
} else {
fmt.Printf("Speed: %.2fMB/s\n", speedMB)
fmt.Printf("Speed: %.0fMB/s\n", speedMB)
if isFast {
fmt.Println("IsFast: true")
} else {

View File

@@ -4,6 +4,7 @@ package fsutils
import (
"bytes"
"math"
"os"
"time"
)
@@ -52,6 +53,7 @@ func CheckDiskWritingSpeed() (speedMB float64, err error) {
var costSeconds = time.Since(before).Seconds()
speedMB = float64(len(data)) / (1 << 20) / costSeconds
speedMB = math.Ceil(speedMB/10) * 10
isClosed = true