Skip to content

Commit

Permalink
Add average request/response size
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Apr 8, 2021
1 parent ace8432 commit 6745eb9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nethttp/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type JobProducer struct {
writeTime int64
bytesRead int64
readTime int64
total int64

f Flags

Expand Down Expand Up @@ -189,8 +190,10 @@ func (j *JobProducer) Print() {
writeTime := atomic.LoadInt64(&j.writeTime)
ulSpeed := float64(bytesWritten) / time.Duration(writeTime).Seconds()

fmt.Println("Bytes read", report.ByteSize(bytesRead), "/", report.ByteSize(int64(dlSpeed))+"/s")
fmt.Println("Bytes written", report.ByteSize(bytesWritten), "/", report.ByteSize(int64(ulSpeed))+"/s")
fmt.Println("Bytes read", report.ByteSize(bytesRead), "total,",
report.ByteSize(bytesRead/atomic.LoadInt64(&j.total)), "avg,", report.ByteSize(int64(dlSpeed))+"/s")
fmt.Println("Bytes written", report.ByteSize(bytesWritten), "total,",
report.ByteSize(bytesWritten/atomic.LoadInt64(&j.total)), "avg,", report.ByteSize(int64(ulSpeed))+"/s")
fmt.Println()

if j.upstreamHist.Count > 0 {
Expand Down Expand Up @@ -361,6 +364,8 @@ func (j *JobProducer) Job(_ int) (time.Duration, error) {
atomic.AddInt64(&j.readTime, int64(done.Sub(dlStart)))
si := done.Sub(start)

atomic.AddInt64(&j.total, 1)

return si, nil
}

Expand Down

0 comments on commit 6745eb9

Please sign in to comment.