mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-07 18:50:27 +08:00
对硬盘写入速度格式化
This commit is contained in:
@@ -436,7 +436,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("[ERROR]" + err.Error())
|
fmt.Println("[ERROR]" + err.Error())
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Speed: %.2fMB/s\n", speedMB)
|
fmt.Printf("Speed: %.0fMB/s\n", speedMB)
|
||||||
if isFast {
|
if isFast {
|
||||||
fmt.Println("IsFast: true")
|
fmt.Println("IsFast: true")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package fsutils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -52,6 +53,7 @@ func CheckDiskWritingSpeed() (speedMB float64, err error) {
|
|||||||
|
|
||||||
var costSeconds = time.Since(before).Seconds()
|
var costSeconds = time.Since(before).Seconds()
|
||||||
speedMB = float64(len(data)) / (1 << 20) / costSeconds
|
speedMB = float64(len(data)) / (1 << 20) / costSeconds
|
||||||
|
speedMB = math.Ceil(speedMB/10) * 10
|
||||||
|
|
||||||
isClosed = true
|
isClosed = true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user