Skip to content

Commit ab44d09

Browse files
committed
Use chunk-based partitioning instead of round-robin
1 parent a1febe6 commit ab44d09

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Asynkron.TestRunner/TestRunner.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,16 @@ await AnsiConsole.Live(display.Render())
158158

159159
private static List<List<string>> SplitIntoBatches(List<string> tests, int batchCount)
160160
{
161+
// Chunk-based: consecutive tests stay together (siblings in same worker)
161162
var batches = new List<List<string>>();
162-
for (var i = 0; i < batchCount; i++)
163-
batches.Add(new List<string>());
163+
var chunkSize = (tests.Count + batchCount - 1) / batchCount; // Ceiling division
164164

165-
// Round-robin distribution for balanced batches
166-
for (var i = 0; i < tests.Count; i++)
167-
batches[i % batchCount].Add(tests[i]);
165+
for (var i = 0; i < batchCount; i++)
166+
{
167+
var start = i * chunkSize;
168+
var count = Math.Min(chunkSize, tests.Count - start);
169+
batches.Add(count > 0 ? tests.GetRange(start, count) : []);
170+
}
168171

169172
return batches;
170173
}

0 commit comments

Comments
 (0)