Skip to content

Commit ea311b6

Browse files
yuukiclaude
andcommitted
refactor: move utility functions to printer module and fix formatting
- Move toMicroseconds and toMicrosecondsf helper functions from client.go to printer.go - These functions are only used by the printer module for latency calculations - Add missing newline at end of printer.go file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5ef2d71 commit ea311b6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

client.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,6 @@ func (c *Client) connectUDP(ctx context.Context, addrport string) error {
306306
return eg.Wait()
307307
}
308308

309-
func toMicroseconds(n int64) int64 {
310-
return time.Duration(n).Microseconds()
311-
}
312-
313-
func toMicrosecondsf(n float64) int64 {
314-
return time.Duration(n).Microseconds()
315-
}
316-
317309
func runStatLinePrinter(ctx context.Context, printer *Printer, addr string, intervalStats time.Duration, mergeResultsEachHost bool) {
318310
go func() {
319311
ticker := time.NewTicker(intervalStats)

printer.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import (
99
"github.com/rcrowley/go-metrics"
1010
)
1111

12+
func toMicroseconds(n int64) int64 {
13+
return time.Duration(n).Microseconds()
14+
}
15+
16+
func toMicrosecondsf(n float64) int64 {
17+
return time.Duration(n).Microseconds()
18+
}
19+
1220
type Printer struct {
1321
writer io.Writer
1422
}
@@ -104,4 +112,4 @@ func (p *Printer) PrintJSONLinesReport(addrs []string, mergeResultsEachHost bool
104112
fmt.Fprintf(p.writer, "Error encoding JSON result: %v\n", err)
105113
}
106114
}
107-
}
115+
}

0 commit comments

Comments
 (0)