Skip to content

Commit

Permalink
Move some statistics computing
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jul 27, 2016
1 parent d38630d commit 9be4c6f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/commands/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,6 @@ func proxyGo(host *config.Host, dryRun bool) error {
result.err = nil
}

stats.DisconnectedAt = time.Now()
stats.ConnectionDuration = stats.DisconnectedAt.Sub(stats.ConnectedAt)
averageSpeed := float64(stats.WrittenBytes) / stats.ConnectionDuration.Seconds()
stats.AverageSpeed = math.Ceil(averageSpeed*1000) / 1000
conn.Close()
cancel()
waitGroup.Wait()
Expand All @@ -315,6 +311,12 @@ func proxyGo(host *config.Host, dryRun bool) error {
stats.WrittenBytes = res.written
default:
}

stats.DisconnectedAt = time.Now()
stats.ConnectionDuration = stats.DisconnectedAt.Sub(stats.ConnectedAt)
averageSpeed := float64(stats.WrittenBytes) / stats.ConnectionDuration.Seconds()
stats.AverageSpeed = math.Ceil(averageSpeed*1000) / 1000

// OnDisconnect hook
Logger.Debugf("Calling OnDisconnect hooks")
if err := host.Hooks.OnDisconnect.InvokeAll(connectHookArgs); err != nil {
Expand Down

0 comments on commit 9be4c6f

Please sign in to comment.