INNER CODE UNIT · Go

fmtDur

bhope/hedge · benchmark/simulate/main.go:96

func fmtDur(d time.Duration) string {
	return fmt.Sprintf("%.1fms", float64(d)/float64(time.Millisecond))
}

func main() {
	var serverHits atomic.Int64

	srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		serverHits.Add(1)
		d := sampleLatency()
		select {
		case <-time.After(d):
			w.WriteHeader(http.StatusOK)
		case <-r.Context().Done():
		}
	}))
	defer srv.Close()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…