func AddStatsWithName(b *testing.B, name string, numBuckets int) *Stats {
	var benchName string
	for i := 1; ; i++ {
		pc, _, _, ok := runtime.Caller(i)
		if !ok {
			panic("benchmark function not found")
		}
		p := strings.Split(runtime.FuncForPC(pc).Name(), ".")
		benchName = p[len(p)-1]
		if strings.HasPrefix(benchName, "Benchmark") {
			break
		}
	}
	procs := runtime.GOMAXPROCS(-1)
	if procs != 1 {
		benchName = fmt.Sprintf("%s-%d", benchName, procs)
	}
	stats := NewStats(numBuckets)
	if injectCond != nil {
		injectCond.L.Lock()
		for curB != nil && curBenchName != benchName {
			injectCond.Wait()
		}
		curB = b
		curBenchName = benchName
		curStats[name] = stats
		injectCond.L.Unlock()
	}
	b.ResetTimer()
	return stats
}
AddStatsWithName adds a new named Stats instance to the current benchmark.
With this, you can add multiple stats in a single benchmark. You need
to run benchmarks by calling RunTestMain() to inject the stats to the
benchmark results. If numBuckets is not positive, the default value (16) will
be used. Please note that this calls b.ResetTimer() since it may be blocked
until the previous benchmark stats is printed out. So AddStatsWithName()
should typically be called at the very beginning of each benchmark function.
package stats
import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"runtime"
	"sort"
	"strings"
	"sync"
	"testing"
)
var (
	curB         *testing.B
	curBenchName string
	curStats     map[string]*Stats
	orgStdout  *os.File
	nextOutPos int
	injectCond *sync.Cond
	injectDone chan struct{}
)
func AddStats(b *testing.B, numBuckets int) *Stats {
	return AddStatsWithName(b, "", numBuckets)
}