Skip to content

Commit

Permalink
removes Dump methods, prefers Stringer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiealquiza committed Aug 29, 2019
1 parent 767a7f5 commit 7d18152
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func main() {
}

// The timing summaries are calculated
// and dumped to console.
fmt.Println(t.Calc().String())
// and printed to console.
fmt.Println(t.Calc())
}
```

Expand Down Expand Up @@ -101,7 +101,7 @@ Output:
### `Metrics`: pre-formatted, multi-line string
```golang
fmt.Println(metrics.String())
fmt.Println(metrics)
```
Output:
Expand Down
2 changes: 1 addition & 1 deletion example/tachymeter-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {
fmt.Printf("%s\n\n", results.JSON())

// Print pre-formatted console output.
fmt.Printf("%s\n\n", results.String())
fmt.Printf("%s\n\n", results)

// Print text histogram.
fmt.Println(results.Histogram.String(15))
Expand Down
2 changes: 1 addition & 1 deletion example/tachymeter-simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {
fmt.Printf("%s\n\n", results.JSON())

// Print pre-formatted console output.
fmt.Printf("%s\n\n", results.String())
fmt.Printf("%s\n\n", results)

// Print text histogram.
fmt.Println(results.Histogram.String(25))
Expand Down
13 changes: 1 addition & 12 deletions tachymeter.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,7 @@ func (m *Metrics) WriteHTML(p string) error {
return w.WriteHTML(p)
}

// Dump prints a formatted Metrics output to console.
func (m *Metrics) Dump() {
fmt.Println(m.String())
}

// String returns a formatted Metrics string.
// String satisfies the String interface.
func (m *Metrics) String() string {
return fmt.Sprintf(`%d samples of %d events
Cumulative: %s
Expand Down Expand Up @@ -241,12 +236,6 @@ func (m *Metrics) MarshalJSON() ([]byte, error) {
})
}

// Dump prints a formatted histogram output to console
// scaled to a width of s.
func (h *Histogram) Dump(s int) {
fmt.Println(h.String(s))
}

// String returns a formatted Metrics string scaled
// to a width of s.
func (h *Histogram) String(s int) string {
Expand Down

0 comments on commit 7d18152

Please sign in to comment.