func testLatency(server stdn.Testserver) error { //perform a full latency test durs, err := server.Ping(fullTestCount) if err != nil { return err } var avg, max, min uint64 var latencies []float64 for i := range durs { ms := uint64(durs[i].Nanoseconds() / 1000000) latencies = append(latencies, float64(ms)) avg += ms if ms > max { max = ms } if ms < min || min == 0 { min = ms } } avg = avg / uint64(len(durs)) median := durs[len(durs)/2].Nanoseconds() / 1000000 sparkline := spark.Line(latencies) fmt.Printf("Latency: %s\t%dms avg\t%dms median\t%dms max\t%dms min\n", sparkline, avg, median, max, min) return nil }
func testUpstream(server stdn.Testserver) error { bps, err := server.Upstream(*speedtestDuration) if err != nil { return err } fmt.Printf("Upload: %s\n", stdn.HumanSpeed(bps)) return nil }