Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion eng/common/scripts/New-RegenerateMatrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ param (
[Parameter()]
[string]$OutputVariableName,

# Both counts are used as divisors when splitting the items, so reject zero and
# negative values here rather than failing later with a divide-by-zero.
[Parameter()]
[ValidateRange(1, [int]::MaxValue)]
[int]$JobCount = 8,

# The minimum number of items per job. If the number of items is less than this, then the number of jobs will be reduced.
[Parameter()]
[ValidateRange(1, [int]::MaxValue)]
[int]$MinimumPerJob = 10,

[Parameter()]
Expand Down Expand Up @@ -40,7 +44,11 @@ function Split-Items([array]$Items) {
}

$itemsPerGroup = [math]::Floor($itemCount / $JobCount)
$largeJobCount = $itemCount % $itemsPerGroup
# The remainder has to be taken over the number of groups, not the size of a group.
# Taking it over $itemsPerGroup produces too few large groups whenever
# $itemCount % $itemsPerGroup -lt $itemCount % $JobCount, and the trailing items are
# then silently dropped from the matrix.
$largeJobCount = $itemCount % $JobCount
$groups = [object[]]::new($JobCount)

$i = 0
Expand Down
Loading