Print PREFETCH only when prefetching

This commit is contained in:
Igor Chubin 2022-11-20 17:54:42 +01:00
parent d4e96dbf3a
commit 5b240c590e

View File

@ -55,10 +55,10 @@ func syncMapLen(sm *sync.Map) int {
func prefetchPeakRequests(peakRequestMap *sync.Map) {
peakRequestLen := syncMapLen(peakRequestMap)
log.Printf("PREFETCH: Prefetching %d requests\n", peakRequestLen)
if peakRequestLen == 0 {
return
}
log.Printf("PREFETCH: Prefetching %d requests\n", peakRequestLen)
sleepBetweenRequests := time.Duration(prefetchInterval*1000/peakRequestLen) * time.Millisecond
peakRequestMap.Range(func(key interface{}, value interface{}) bool {
go func(r http.Request) {