From 87336a01181e51dd64093d29d4731e6afc5de17f Mon Sep 17 00:00:00 2001 From: maintell Date: Tue, 12 Apr 2022 14:25:30 +0800 Subject: [PATCH] 1\ fix version code 2\ show total bytes of network nic. 3\ add default target by a very big file Signed-off-by: maintell --- go.mod | 1 + go.sum | 2 ++ main.go | 11 ++++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 55c1393..affc5c5 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect github.com/apoorvam/goterminal v0.0.0-20180523175556-614d345c47e5 github.com/go-ole/go-ole v1.2.5 // indirect + github.com/liushuochen/gotable v0.0.0-20220408160921-3255800d3de2 github.com/mattn/go-isatty v0.0.12 // indirect github.com/miekg/dns v1.1.43 github.com/shirou/gopsutil v3.21.4+incompatible diff --git a/go.sum b/go.sum index f92b5b1..7efc04e 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/liushuochen/gotable v0.0.0-20220408160921-3255800d3de2 h1:YJRuaK9I9EaloWTmtchFW715uSz1oATKsdTkOZzdP+Q= +github.com/liushuochen/gotable v0.0.0-20220408160921-3255800d3de2/go.mod h1:CxUy8nDvutaC1pOfaG9TRoYwdHHqoNstSPPKhomC9k8= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg= diff --git a/main.go b/main.go index 0aa5dec..b5b0e28 100644 --- a/main.go +++ b/main.go @@ -129,7 +129,6 @@ func LeastSquares(x []float64, y []float64) (a float64, b float64) { } func showStat() { - initialNetCounter, _ := netstat.IOCounters(true) iplist := "" if customIP !=nil && len(customIP)>0{ @@ -181,8 +180,10 @@ func showStat() { // _, b := LeastSquares(x, y) // log.Printf("Speed Vertical:%.3f\n", b) //} - fmt.Fprintf(TerminalWriter, "Nic:%v,Recv %s/s,Send %s/s\n", netCounter[i].Name, + fmt.Fprintf(TerminalWriter, "Nic:%v,Recv %s(%s/s),Send %s(%s/s)\n", netCounter[i].Name, + readableBytes(float64(netCounter[i].BytesRecv)), readableBytes(RecvBytes), + readableBytes(float64(netCounter[i].BytesSent)), readableBytes(SendBytes)) } initialNetCounter = netCounter @@ -329,8 +330,8 @@ func goFun(Url string, postContent string, Referer string, XforwardFor bool, cus wg.Done() } var h = flag.Bool("h", false, "this help") -var count = flag.Int("c", 16, "concurrent thread for download,default 8") -var url = flag.String("s", "https://baidu.com", "target url") +var count = flag.Int("c", 16, "concurrent thread for download,default 16") +var url = flag.String("s", "http://speedtest4.tele2.net/1GB.zip", "target url") var postContent = flag.String("p", "", "post content") var referer = flag.String("r", "", "referer url") var xforwardfor = flag.Bool("f", true, "randomized X-Forwarded-For and X-Real-IP address") @@ -340,7 +341,7 @@ var headers headersList func usage() { fmt.Fprintf(os.Stderr, -`webBenchmark version: /0.4 +`webBenchmark version: /0.5 Usage: webBenchmark [-c concurrent] [-s target] [-p] [-r refererUrl] [-f] [-i ip] Options: