MCPcopy
hub / github.com/nats-io/nats.go / MsgsPerClient

Function MsgsPerClient

bench/bench.go:342–357  ·  view source on GitHub ↗

MsgsPerClient divides the number of messages by the number of clients and tries to distribute them as evenly as possible

(numMsgs, numClients int)

Source from the content-addressed store, hash-verified

340
341// MsgsPerClient divides the number of messages by the number of clients and tries to distribute them as evenly as possible
342func MsgsPerClient(numMsgs, numClients int) []int {
343 var counts []int
344 if numClients == 0 || numMsgs == 0 {
345 return counts
346 }
347 counts = make([]int, numClients)
348 mc := numMsgs / numClients
349 for i := 0; i < numClients; i++ {
350 counts[i] = mc
351 }
352 extra := numMsgs % numClients
353 for i := 0; i < extra; i++ {
354 counts[i]++
355 }
356 return counts
357}

Callers 2

mainFunction · 0.92
TestMsgsPerClientFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestMsgsPerClientFunction · 0.68