code: func (pm *ProtocolManager) runBenchmark(benchmarks []requestBenchmark, passCount int, targetTime time.Duration) []*benchmarkSetup {
  	setup := make([]*benchmarkSetup, len(benchmarks))
  	for i, b := range benchmarks {
  		setup[i] = &benchmarkSetup{req: b}
  	}
  	for i := 0; i < passCount; i++ {
  		log.Info("Running benchmark", "pass", i+1, "total", passCount)
  		todo := make([]*benchmarkSetup, len(benchmarks))
  		copy(todo, setup)
  		for len(todo) > 0 {
  			// select a random element
  			index := rand.Intn(len(todo))
  			next := todo[index]
  			todo[index] = todo[len(todo)-1]
  			todo = todo[:len(todo)-1]
  
  			if next.err == nil {
  				// calculate request count
  				count := 50
  				if next.totalTime > 0 {
  					count = int(uint64(next.totalCount) * uint64(targetTime) / uint64(next.totalTime))
  				}
  				if err := pm.measure(next, count); err != nil {
  					next.err = err
  				}
  			}
  		}
  	}
  	log.Info("Benchmark completed")
  
  	for _, s := range setup {
  		if s.err == nil {
  			s.avgTime = s.totalTime / time.Duration(s.totalCount)
  		}
  	}
  	return setup
  }
docs: // runBenchmark runs a benchmark cycle for all benchmark types in the specified
  // number of passes