19 lines
392 B
Go
19 lines
392 B
Go
package loadsim
|
|
|
|
func ConnectionBatches(total int, ratePerSecond int) []int {
|
|
if total <= 0 || ratePerSecond <= 0 {
|
|
return nil
|
|
}
|
|
batches := make([]int, 0, (total+ratePerSecond-1)/ratePerSecond)
|
|
remaining := total
|
|
for remaining > 0 {
|
|
batch := ratePerSecond
|
|
if remaining < batch {
|
|
batch = remaining
|
|
}
|
|
batches = append(batches, batch)
|
|
remaining -= batch
|
|
}
|
|
return batches
|
|
}
|