INNER CODE UNIT · Go
sigma
bhope/hedge · benchmark/streaming/main.go:88
sigma := math.Sqrt(math.Log(1 + cv2))
mu := math.Log(meanNs) - sigma*sigma/2
return mu, sigma
}
// sampleTTFT draws a first-token latency from the configured distribution.
func sampleTTFT() time.Duration {
if rand.Float64() < cacheMissRate {
return time.Duration(math.Exp(missMu + missSigma*rand.NormFloat64()))
}
return time.Duration(math.Exp(hitMu + hitSigma*rand.NormFloat64()))
}
// ── test servers ────────────────────────────────────────────────────────────
// newStreamingServer flushes 200 OK headers immediately then writes the first
// body byte only after the TTFT delay. This separates header arrival from
// first-token time and makes TTFB measurement produce near-zero observations.