refactor(analytic): improved network stat #913

This commit is contained in:
Jacky 2025-03-15 09:09:53 +08:00
parent ec29a77f99
commit 789698a0d4
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
6 changed files with 247 additions and 108 deletions

View file

@ -2,14 +2,15 @@ package test
import (
"fmt"
"runtime"
"testing"
"time"
"github.com/0xJacky/Nginx-UI/internal/analytic"
"github.com/shirou/gopsutil/v4/cpu"
"github.com/shirou/gopsutil/v4/disk"
"github.com/shirou/gopsutil/v4/load"
"github.com/shirou/gopsutil/v4/mem"
"github.com/shirou/gopsutil/v4/net"
"runtime"
"testing"
"time"
)
func TestGoPsutil(t *testing.T) {
@ -35,9 +36,9 @@ func TestGoPsutil(t *testing.T) {
diskUsage, _ := disk.Usage(".")
fmt.Println(diskUsage.String())
network, _ := net.IOCounters(false)
network, _ := analytic.GetNetworkStat()
fmt.Println(network)
time.Sleep(time.Second)
network, _ = net.IOCounters(false)
network, _ = analytic.GetNetworkStat()
fmt.Println(network)
}