perf(probe): reduce copying of nodes

Where we know we are merging several reports into the one, we can call
UnsafeMerge() and skip the copy that Merge() will do.
This commit is contained in:
Bryan Boreham
2019-09-15 13:39:08 +00:00
parent ce73474851
commit 2f9c9913c4

View File

@@ -183,7 +183,7 @@ func (p *Probe) report() report.Report {
result := report.MakeReport()
for i := 0; i < cap(reports); i++ {
result = result.Merge(<-reports)
result.UnsafeMerge(<-reports)
}
return result
}
@@ -210,11 +210,12 @@ func (p *Probe) tag(r report.Report) report.Report {
func (p *Probe) drainAndPublish(rpt report.Report, rs chan report.Report) {
p.rateLimiter.Wait(context.Background())
rpt = rpt.Copy()
ForLoop:
for {
select {
case r := <-rs:
rpt = rpt.Merge(r)
rpt.UnsafeMerge(r)
default:
break ForLoop
}