Created
January 9, 2017 09:57
-
-
Save sepehrmm/0c46f3b6cc417c9db21c15f767197c4a to your computer and use it in GitHub Desktop.
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
package main | |
import( | |
"fmt" | |
"time" | |
"github.com/sparrc/go-ping" | |
) | |
func main(){ | |
pinger, err := ping.NewPinger("www.atroot.com") | |
if err != nil { | |
panic(err) | |
} | |
pinger.Count = 3 | |
pinger.Run() // blocks until finished | |
stats := pinger.Statistics() // get send/receive/rtt stats | |
latency := stats.AvgRtt // stats.AvgRtt is time.Duration type | |
jitter := stats.StdDevRtt// stats.StdDevRtt is time.Duration type | |
fmt.Printf("latency: %T , %d , %v \n", latency, latency, latency) | |
fmt.Printf("jitter: %T , %d , %v \n", jitter, jitter, jitter) | |
latencyAsMicroSecond := int64(latency / time.Microsecond) | |
jitterAsMicroSecond := int64(jitter / time.Microsecond) | |
fmt.Printf("latencyAsMicroSecond: %T , %d , %v \n", latencyAsMicroSecond, latencyAsMicroSecond, latencyAsMicroSecond) | |
fmt.Printf("jitterAsMicroSecond: %T , %d , %v \n", jitterAsMicroSecond, jitterAsMicroSecond, jitterAsMicroSecond) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for http://stackoverflow.com/questions/41503758/conversion-of-time-duration-type-microseconds-value-to-milliseconds-in-golang