MCPcopy
hub / github.com/uber-go/zap / getBenchmarkRows

Function getBenchmarkRows

internal/readme/readme.go:94–128  ·  view source on GitHub ↗
(benchmarkName string)

Source from the content-addressed store, hash-verified

92}
93
94func getBenchmarkRows(benchmarkName string) (string, error) {
95 benchmarkOutput, err := getBenchmarkOutput(benchmarkName)
96 if err != nil {
97 return "", err
98 }
99
100 // get the Zap time (unsugared) as baseline to compare with other loggers
101 baseline, err := getBenchmarkRow(benchmarkOutput, benchmarkName, "Zap", nil)
102 if err != nil {
103 return "", err
104 }
105
106 var benchmarkRows []*benchmarkRow
107 for libraryName := range libraryNameToMarkdownName {
108 benchmarkRow, err := getBenchmarkRow(
109 benchmarkOutput, benchmarkName, libraryName, baseline,
110 )
111 if err != nil {
112 return "", err
113 }
114 if benchmarkRow == nil {
115 continue
116 }
117 benchmarkRows = append(benchmarkRows, benchmarkRow)
118 }
119 sort.Sort(benchmarkRowsByTime(benchmarkRows))
120 rows := []string{
121 "| Package | Time | Time % to zap | Objects Allocated |",
122 "| :------ | :--: | :-----------: | :---------------: |",
123 }
124 for _, benchmarkRow := range benchmarkRows {
125 rows = append(rows, benchmarkRow.String())
126 }
127 return strings.Join(rows, "\n"), nil
128}
129
130func getBenchmarkRow(
131 input []string, benchmarkName string, libraryName string, baseline *benchmarkRow,

Callers 1

getTmplDataFunction · 0.85

Calls 4

getBenchmarkOutputFunction · 0.85
getBenchmarkRowFunction · 0.85
benchmarkRowsByTimeTypeAlias · 0.85
StringMethod · 0.45

Tested by

no test coverage detected