From cc6a129e3f9d143654a61fa17dfd2437a3cd982f Mon Sep 17 00:00:00 2001 From: lonord Date: Tue, 19 Jun 2018 22:27:58 +0800 Subject: [PATCH] fix bug of net speed moniting --- build.sh | 2 +- netutil/netspeed.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index bd7a572..3a3a789 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSION=1.0 +VERSION=1.1 cd $(dirname $0) diff --git a/netutil/netspeed.go b/netutil/netspeed.go index 927b05a..3fc603f 100644 --- a/netutil/netspeed.go +++ b/netutil/netspeed.go @@ -49,13 +49,13 @@ func (n *NetSpeedReader) Read() ([]NetSpeed, error) { return nil, err } sMap := convertToDevStatusMapWithFilter(s, n.targetDevs) - speedList := cal(sMap, ls, int((t.UnixNano()-lt.UnixNano())/1000000)) + speedList := cal(ls, sMap, uint64((t.UnixNano()-lt.UnixNano())/1000000)) n.recordTime = t n.statusMap = sMap return speedList, nil } -func MeasureNetSpeed(timeSpanMilli int) ([]NetSpeed, error) { +func MeasureNetSpeed(timeSpanMilli uint64) ([]NetSpeed, error) { status1, err := readDevStatusDefault() if err != nil { return nil, err @@ -74,7 +74,7 @@ func readDevStatusDefault() ([]DevStatus, error) { return ReadDevStatus(ba.DefaultFileReader) } -func cal(map1, map2 map[string]DevStatus, timeSpanMilli int) []NetSpeed { +func cal(map1, map2 map[string]DevStatus, timeSpanMilli uint64) []NetSpeed { speedList := []NetSpeed{} for name := range map2 { s1, ok1 := map1[name]