fix #14
This commit is contained in:
parent
0ac037cfc0
commit
fa71e924d2
3
main.go
3
main.go
|
@ -35,6 +35,7 @@ var (
|
|||
socks5 = kingpin.Flag("socks5", "Socks5 proxy").PlaceHolder("ip:port").String()
|
||||
|
||||
autoOpenBrowser = kingpin.Flag("auto-open-browser", "Specify whether auto open browser to show Web charts").Bool()
|
||||
notClearBar = kingpin.Flag("not-clear", "Don't clear the histogram bar once its finished").Bool()
|
||||
|
||||
url = kingpin.Arg("url", "request url").Required().String()
|
||||
)
|
||||
|
@ -207,6 +208,6 @@ func main() {
|
|||
}
|
||||
|
||||
// terminal printer
|
||||
printer := NewPrinter(*requests, *duration)
|
||||
printer := NewPrinter(*requests, *duration, *notClearBar)
|
||||
printer.PrintLoop(report.Snapshot, *interval, *seconds, report.Done())
|
||||
}
|
||||
|
|
8
print.go
8
print.go
|
@ -32,10 +32,11 @@ type Printer struct {
|
|||
pbInc int64
|
||||
pbNumStr string
|
||||
pbDurStr string
|
||||
notClearBar bool
|
||||
}
|
||||
|
||||
func NewPrinter(maxNum int64, maxDuration time.Duration) *Printer {
|
||||
return &Printer{maxNum: maxNum, maxDuration: maxDuration}
|
||||
func NewPrinter(maxNum int64, maxDuration time.Duration, notClearBar bool) *Printer {
|
||||
return &Printer{maxNum: maxNum, maxDuration: maxDuration, notClearBar: notClearBar}
|
||||
}
|
||||
|
||||
func (p *Printer) updateProgressValue(rs *SnapshotReport) {
|
||||
|
@ -219,7 +220,8 @@ func (p *Printer) buildHistogram(snapshot *SnapshotReport, useSeconds bool, isFi
|
|||
row := []string{durationToString(bin.Mean, useSeconds), strconv.Itoa(bin.Count)}
|
||||
if isFinal {
|
||||
row = append(row, fmt.Sprintf("%.2f%%", math.Floor(float64(bin.Count)*1e4/float64(hisSum)+0.5)/100.0))
|
||||
} else {
|
||||
}
|
||||
if !isFinal || p.notClearBar {
|
||||
barLen := 0
|
||||
if maxCount > 0 {
|
||||
barLen = (bin.Count*maxBarLen + maxCount/2) / maxCount
|
||||
|
|
Loading…
Reference in New Issue