( input []string, benchmarkName string, libraryName string, baseline *benchmarkRow, )
| 128 | } |
| 129 | |
| 130 | func getBenchmarkRow( |
| 131 | input []string, benchmarkName string, libraryName string, baseline *benchmarkRow, |
| 132 | ) (*benchmarkRow, error) { |
| 133 | line, err := findUniqueSubstring(input, fmt.Sprintf("%s/%s-", benchmarkName, libraryName)) |
| 134 | if err != nil { |
| 135 | return nil, err |
| 136 | } |
| 137 | if line == "" { |
| 138 | return nil, nil |
| 139 | } |
| 140 | split := strings.Split(line, "\t") |
| 141 | if len(split) < 5 { |
| 142 | return nil, fmt.Errorf("unknown benchmark line: %s", line) |
| 143 | } |
| 144 | duration, err := time.ParseDuration(strings.ReplaceAll(strings.TrimSuffix(strings.TrimSpace(split[2]), "/op"), " ", "")) |
| 145 | if err != nil { |
| 146 | return nil, err |
| 147 | } |
| 148 | allocatedBytes, err := strconv.Atoi(strings.TrimSuffix(strings.TrimSpace(split[3]), " B/op")) |
| 149 | if err != nil { |
| 150 | return nil, err |
| 151 | } |
| 152 | allocatedObjects, err := strconv.Atoi(strings.TrimSuffix(strings.TrimSpace(split[4]), " allocs/op")) |
| 153 | if err != nil { |
| 154 | return nil, err |
| 155 | } |
| 156 | r := &benchmarkRow{ |
| 157 | Name: libraryNameToMarkdownName[libraryName], |
| 158 | Time: duration, |
| 159 | AllocatedBytes: allocatedBytes, |
| 160 | AllocatedObjects: allocatedObjects, |
| 161 | } |
| 162 | |
| 163 | if baseline != nil { |
| 164 | r.ZapTime = baseline.Time |
| 165 | r.ZapAllocatedBytes = baseline.AllocatedBytes |
| 166 | r.ZapAllocatedObjects = baseline.AllocatedObjects |
| 167 | } |
| 168 | |
| 169 | return r, nil |
| 170 | } |
| 171 | |
| 172 | func findUniqueSubstring(input []string, substring string) (string, error) { |
| 173 | var output string |
no test coverage detected