-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fix: remove RTT tracking from client/transport in favor of di…
…rect tra…"
- Loading branch information
Showing
6 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ftwhttp | ||
|
||
import "time" | ||
|
||
// NewRoundTripTime initializes a roundtriptime struct | ||
func NewRoundTripTime() *RoundTripTime { | ||
rtt := &RoundTripTime{ | ||
begin: time.Now(), | ||
end: time.Now(), | ||
} | ||
|
||
return rtt | ||
} | ||
|
||
// StartTracking sets the initial time to Now | ||
func (rtt *RoundTripTime) StartTracking() { | ||
rtt.begin = time.Now() | ||
} | ||
|
||
// StopTracking sets the finish time to Now | ||
func (rtt *RoundTripTime) StopTracking() { | ||
now := time.Now() | ||
rtt.end = now.Add(50 * time.Millisecond) | ||
} | ||
|
||
// StartTime returns the time when this round trip started | ||
func (rtt *RoundTripTime) StartTime() time.Time { | ||
return rtt.begin | ||
} | ||
|
||
// StopTime returns the time when this round trip was stopped | ||
func (rtt *RoundTripTime) StopTime() time.Time { | ||
return rtt.end | ||
} | ||
|
||
// RoundTripDuration gives the total time spent in this roundtrip | ||
func (rtt *RoundTripTime) RoundTripDuration() time.Duration { | ||
return rtt.end.Sub(rtt.begin) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters