From 57329a26c86696abbca741a29af42b087c50bafa Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 29 Mar 2023 20:56:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=A6=82?= =?UTF-8?q?=E8=A7=88=E9=A1=B5=20io=20=E5=BB=B6=E8=BF=9F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=20(#441)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/dashboard.go | 3 ++- backend/app/service/dashboard.go | 13 +++++-------- cmd/server/docs/docs.go | 5 ++++- cmd/server/docs/swagger.json | 5 ++++- cmd/server/docs/swagger.yaml | 4 +++- frontend/src/api/interface/dashboard.ts | 3 ++- frontend/src/views/home/index.vue | 12 +++++++++--- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/backend/app/dto/dashboard.go b/backend/app/dto/dashboard.go index 565d03009..3afb240ad 100644 --- a/backend/app/dto/dashboard.go +++ b/backend/app/dto/dashboard.go @@ -55,7 +55,8 @@ type DashboardCurrent struct { IOReadBytes uint64 `json:"ioReadBytes"` IOWriteBytes uint64 `json:"ioWriteBytes"` IOCount uint64 `json:"ioCount"` - IOTime uint64 `json:"ioTime"` + IOReadTime uint64 `json:"ioReadTime"` + IOWriteTime uint64 `json:"ioWriteTime"` Total uint64 `json:"total"` Free uint64 `json:"free"` diff --git a/backend/app/service/dashboard.go b/backend/app/service/dashboard.go index d40cf0e55..35d4d7d7d 100644 --- a/backend/app/service/dashboard.go +++ b/backend/app/service/dashboard.go @@ -136,20 +136,17 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d currentInfo.IOReadBytes += state.ReadBytes currentInfo.IOWriteBytes += state.WriteBytes currentInfo.IOCount += (state.ReadCount + state.WriteCount) - currentInfo.IOTime += state.ReadTime / 1000 / 1000 - if state.WriteTime > state.ReadTime { - currentInfo.IOTime += state.WriteTime / 1000 / 1000 - } + currentInfo.IOReadTime += state.ReadTime + currentInfo.IOWriteTime += state.WriteTime } } else { diskInfo, _ := disk.IOCounters(ioOption) for _, state := range diskInfo { currentInfo.IOReadBytes += state.ReadBytes currentInfo.IOWriteBytes += state.WriteBytes - currentInfo.IOTime += state.ReadTime / 1000 / 1000 - if state.WriteTime > state.ReadTime { - currentInfo.IOTime += state.WriteTime / 1000 / 1000 - } + currentInfo.IOCount += (state.ReadCount + state.WriteCount) + currentInfo.IOReadTime += state.ReadTime + currentInfo.IOWriteTime += state.WriteTime } } diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 53a6c05a4..65f94535c 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -9260,12 +9260,15 @@ var doc = `{ "ioReadBytes": { "type": "integer" }, - "ioTime": { + "ioReadTime": { "type": "integer" }, "ioWriteBytes": { "type": "integer" }, + "ioWriteTime": { + "type": "integer" + }, "load1": { "type": "number" }, diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 8d14d9c74..6ca3aca43 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -9246,12 +9246,15 @@ "ioReadBytes": { "type": "integer" }, - "ioTime": { + "ioReadTime": { "type": "integer" }, "ioWriteBytes": { "type": "integer" }, + "ioWriteTime": { + "type": "integer" + }, "load1": { "type": "number" }, diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index b8b570c62..49d223355 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -502,10 +502,12 @@ definitions: type: integer ioReadBytes: type: integer - ioTime: + ioReadTime: type: integer ioWriteBytes: type: integer + ioWriteTime: + type: integer load1: type: number load5: diff --git a/frontend/src/api/interface/dashboard.ts b/frontend/src/api/interface/dashboard.ts index 1e4e77f08..93eebb67c 100644 --- a/frontend/src/api/interface/dashboard.ts +++ b/frontend/src/api/interface/dashboard.ts @@ -49,8 +49,9 @@ export namespace Dashboard { ioReadBytes: number; ioWriteBytes: number; - ioTime: number; ioCount: number; + ioReadTime: number; + ioWriteTime: number; total: number; free: number; diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index 35881ab88..d43cbf6ce 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -104,7 +104,7 @@ {{ $t('home.rwPerSecond') }}: {{ currentChartInfo.ioCount }} {{ $t('home.time') }} - {{ $t('home.ioDelay') }}: {{ currentInfo.ioTime }} ms + {{ $t('home.ioDelay') }}: {{ currentChartInfo.ioTime }} ms
@@ -282,8 +282,9 @@ const currentInfo = ref({ ioReadBytes: 0, ioWriteBytes: 0, - ioTime: 0, ioCount: 0, + ioReadTime: 0, + ioWriteTime: 0, total: 0, free: 0, @@ -304,6 +305,7 @@ const currentChartInfo = reactive({ ioReadBytes: 0, ioWriteBytes: 0, ioCount: 0, + ioTime: 0, netBytesSent: 0, netBytesRecv: 0, @@ -389,7 +391,11 @@ const onLoadCurrentInfo = async () => { if (ioWriteBytes.value.length > 20) { ioWriteBytes.value.splice(0, 1); } - currentChartInfo.ioCount = Number(((res.data.ioCount - currentInfo.value.ioCount) / 3).toFixed(2)); + currentChartInfo.ioCount = Math.round(Number((res.data.ioCount - currentInfo.value.ioCount) / 3)); + let ioReadTime = res.data.ioReadTime - currentInfo.value.ioReadTime; + let ioWriteTime = res.data.ioWriteTime - currentInfo.value.ioWriteTime; + let ioChoose = ioReadTime > ioWriteTime ? ioReadTime : ioWriteTime; + currentChartInfo.ioTime = Math.round(Number(ioChoose / 3)); timeIODatas.value.push(dateFormatForSecond(res.data.shotTime)); if (timeIODatas.value.length > 20) {