MCPcopy Index your code
hub / github.com/coder/coder / Write

Method Write

cli/ping.go:64–79  ·  view source on GitHub ↗

Write finalizes the summary and writes it

(w io.Writer)

Source from the content-addressed store, hash-verified

62
63// Write finalizes the summary and writes it
64func (s *pingSummary) Write(w io.Writer) {
65 if s.Successful > 0 {
66 s.Avg = ptr.Ref(time.Duration(s.latencySum / float64(s.Successful) * float64(time.Second)))
67 }
68 if s.Successful > 1 {
69 s.Variance = ptr.Ref(time.Duration((s.m2 / float64(s.Successful-1)) * float64(time.Second)))
70 }
71 out, err := cliui.DisplayTable([]*pingSummary{s}, "", nil)
72 if err != nil {
73 _, _ = fmt.Fprintf(w, "Failed to display ping summary: %v\n", err)
74 return
75 }
76 width := len(strings.Split(out, "\n")[0])
77 _, _ = fmt.Println(strings.Repeat("-", width))
78 _, _ = fmt.Fprint(w, out)
79}
80
81func (r *RootCmd) ping() *serpent.Command {
82 var (

Callers 2

pingMethod · 0.95
TestBuildSummaryFunction · 0.95

Calls 3

RefFunction · 0.92
DisplayTableFunction · 0.92
DurationMethod · 0.80

Tested by 1

TestBuildSummaryFunction · 0.76