dae/component/outbound/dialer/utils.go

22 lines
498 B
Go
Raw Normal View History

2023-07-10 18:44:56 +07:00
package dialer
import "time"
func showDuration(d time.Duration) string {
return d.Truncate(time.Millisecond).String()
}
func latencyString(realLatency, latencyOffset time.Duration) string {
var offsetSign string = "+"
if latencyOffset < 0 {
offsetSign = "-"
2023-07-10 18:44:56 +07:00
}
var offsetPart string = ""
if latencyOffset != 0 {
offsetPart = "(" + offsetSign + showDuration(latencyOffset.Abs()) + "=" + showDuration(realLatency+latencyOffset) + ")"
}
return showDuration(realLatency) + offsetPart
2023-07-10 18:44:56 +07:00
}