INNER CODE UNIT · Go
overhead
bhope/hedge · benchmark/simulate/main.go:85
overhead := float64(hits-numRequests) / float64(numRequests) * 100
sort.Slice(latencies, func(i, j int) bool { return latencies[i] < latencies[j] })
return simResult{latencies: latencies, overhead: overhead}
}
func pct(sorted []time.Duration, p float64) time.Duration {
idx := int(float64(len(sorted)-1) * p)
return sorted[idx]
}
func fmtDur(d time.Duration) string {
return fmt.Sprintf("%.1fms", float64(d)/float64(time.Millisecond))
}
func main() {
var serverHits atomic.Int64