| 258 | } |
| 259 | |
| 260 | func report( |
| 261 | producers []*producer.Producer, |
| 262 | consumers []*consumer.Consumer, |
| 263 | indexers []esutil.BulkIndexer, |
| 264 | ) string { |
| 265 | var ( |
| 266 | b strings.Builder |
| 267 | |
| 268 | value string |
| 269 | currRow = 1 |
| 270 | numCols = 6 |
| 271 | colWidth = 20 |
| 272 | |
| 273 | divider = func(last bool) { |
| 274 | fmt.Fprintf(&b, "\033[%d;0H", currRow) |
| 275 | fmt.Fprint(&b, "┣") |
| 276 | for i := 1; i <= numCols; i++ { |
| 277 | fmt.Fprint(&b, strings.Repeat("━", colWidth)) |
| 278 | if last && i == 5 { |
| 279 | fmt.Fprint(&b, "┷") |
| 280 | continue |
| 281 | } |
| 282 | if i < numCols { |
| 283 | fmt.Fprint(&b, "┿") |
| 284 | } |
| 285 | } |
| 286 | fmt.Fprint(&b, "┫") |
| 287 | currRow++ |
| 288 | } |
| 289 | ) |
| 290 | |
| 291 | fmt.Print("\033[2J\033[K") |
| 292 | fmt.Printf("\033[%d;0H", currRow) |
| 293 | |
| 294 | fmt.Fprint(&b, "┏") |
| 295 | for i := 1; i <= numCols; i++ { |
| 296 | fmt.Fprint(&b, strings.Repeat("━", colWidth)) |
| 297 | if i < numCols { |
| 298 | fmt.Fprint(&b, "┯") |
| 299 | } |
| 300 | } |
| 301 | fmt.Fprint(&b, "┓") |
| 302 | currRow++ |
| 303 | |
| 304 | for i, p := range producers { |
| 305 | fmt.Fprintf(&b, "\033[%d;0H", currRow) |
| 306 | value = fmt.Sprintf("Producer %d", i+1) |
| 307 | fmt.Fprintf(&b, "┃ %-*s│", colWidth-1, value) |
| 308 | s := p.Stats() |
| 309 | value = fmt.Sprintf("duration=%s", s.Duration.Truncate(time.Second)) |
| 310 | fmt.Fprintf(&b, " %-*s│", colWidth-1, value) |
| 311 | value = fmt.Sprintf("msg/sec=%s", humanize.FtoaWithDigits(s.Throughput, 2)) |
| 312 | fmt.Fprintf(&b, " %-*s│", colWidth-1, value) |
| 313 | value = fmt.Sprintf("sent=%s", humanize.Comma(int64(s.TotalMessages))) |
| 314 | fmt.Fprintf(&b, " %-*s│", colWidth-1, value) |
| 315 | value = fmt.Sprintf("bytes=%s", humanize.Bytes(uint64(s.TotalBytes))) |
| 316 | fmt.Fprintf(&b, " %-*s│", colWidth-1, value) |
| 317 | value = fmt.Sprintf("errors=%s", humanize.Comma(int64(s.TotalErrors))) |