MCPcopy
hub / github.com/nats-io/nats.go / Report

Method Report

bench/bench.go:270–302  ·  view source on GitHub ↗

Report returns a human readable report of the samples taken in the Benchmark

()

Source from the content-addressed store, hash-verified

268
269// Report returns a human readable report of the samples taken in the Benchmark
270func (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
304func commaFormat(n int64) string {
305 in := strconv.FormatInt(n, 10)

Callers 2

mainFunction · 0.80
TestBenchStringsFunction · 0.80

Calls 3

HasSamplesMethod · 0.80
StatisticsMethod · 0.80
StringMethod · 0.45

Tested by 1

TestBenchStringsFunction · 0.64