Report returns a human readable report of the samples taken in the Benchmark
()
| 268 | |
| 269 | // Report returns a human readable report of the samples taken in the Benchmark |
| 270 | func (bm *Benchmark) Report() string { |
| 271 | var buffer bytes.Buffer |
| 272 | |
| 273 | indent := "" |
| 274 | if !bm.Pubs.HasSamples() && !bm.Subs.HasSamples() { |
| 275 | return "No publisher or subscribers. Nothing to report." |
| 276 | } |
| 277 | |
| 278 | if bm.Pubs.HasSamples() && bm.Subs.HasSamples() { |
| 279 | buffer.WriteString(fmt.Sprintf("%s Pub/Sub stats: %s\n", bm.Name, bm)) |
| 280 | indent += " " |
| 281 | } |
| 282 | if bm.Pubs.HasSamples() { |
| 283 | buffer.WriteString(fmt.Sprintf("%sPub stats: %s\n", indent, bm.Pubs)) |
| 284 | if len(bm.Pubs.Samples) > 1 { |
| 285 | for i, stat := range bm.Pubs.Samples { |
| 286 | buffer.WriteString(fmt.Sprintf("%s [%d] %v (%d msgs)\n", indent, i+1, stat, stat.JobMsgCnt)) |
| 287 | } |
| 288 | buffer.WriteString(fmt.Sprintf("%s %s\n", indent, bm.Pubs.Statistics())) |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | if bm.Subs.HasSamples() { |
| 293 | buffer.WriteString(fmt.Sprintf("%sSub stats: %s\n", indent, bm.Subs)) |
| 294 | if len(bm.Subs.Samples) > 1 { |
| 295 | for i, stat := range bm.Subs.Samples { |
| 296 | buffer.WriteString(fmt.Sprintf("%s [%d] %v (%d msgs)\n", indent, i+1, stat, stat.JobMsgCnt)) |
| 297 | } |
| 298 | buffer.WriteString(fmt.Sprintf("%s %s\n", indent, bm.Subs.Statistics())) |
| 299 | } |
| 300 | } |
| 301 | return buffer.String() |
| 302 | } |
| 303 | |
| 304 | func commaFormat(n int64) string { |
| 305 | in := strconv.FormatInt(n, 10) |