Files
lingniu-vehicle-ingest/go/vehicle-gateway/internal/loadsim/schedule.go
2026-07-03 17:55:22 +08:00

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
}