MCPcopy Index your code
hub / github.com/microsoft/ethr / durationToString

Function durationToString

utils.go:132–159  ·  view source on GitHub ↗
(d time.Duration)

Source from the content-addressed store, hash-verified

130}
131
132func durationToString(d time.Duration) string {
133 if d < 0 {
134 return d.String()
135 }
136 ud := uint64(d)
137 val := float64(ud)
138 unit := ""
139 if ud < uint64(60*time.Second) {
140 switch {
141 case ud < uint64(time.Microsecond):
142 unit = "ns"
143 case ud < uint64(time.Millisecond):
144 val = val / 1000
145 unit = "us"
146 case ud < uint64(time.Second):
147 val = val / (1000 * 1000)
148 unit = "ms"
149 default:
150 val = val / (1000 * 1000 * 1000)
151 unit = "s"
152 }
153
154 result := strconv.FormatFloat(val, 'f', 3, 64)
155 return result + unit
156 }
157
158 return d.String()
159}
160
161func protoToString(proto EthrProtocol) string {
162 switch proto {

Callers 8

getTestResultsFunction · 0.85
emitLatencyResultsMethod · 0.85
printTestResultFunction · 0.85
logLatencyFunction · 0.85
tcpRunPingFunction · 0.85
tcpDiscoverHopsFunction · 0.85
icmpRunPingFunction · 0.85
icmpDiscoverHopsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected