-
Notifications
You must be signed in to change notification settings - Fork 1
Test parallelization
Damian Terlecki edited this page Oct 5, 2019
·
1 revision
Sorting tests by execution time - execute tests and export them as HTML.
const tests = [...document.querySelectorAll(".level.test > span")]
.map(e => e.innerText)
.map(e => e.replace("\npassed\n", " "))
.map(t => ({name: t.split(" ")[2], time: (t.split(" ")[0] * (t.split(" ")[1] === "s" ? 1000 : 1))}))
.sort((a, b) => a.time - b.time);
Filtering by @SmallTest
tests.filter(t => t.time < 1000);
Filtering by @MediumTest
tests.filter(t => t.time < 10000);
Filtering by @LargeTest
tests.filter(t => t.time >= 10000);
Grouping into 3 sets:
function groupBy(list, keyGetter) {
const map = new Map();
list.forEach((item) => {
const key = keyGetter(item);
const collection = map.get(key);
if (!collection) {
map.set(key, [item]);
} else {
collection.push(item);
}
});
return map;
}
function groupEqualizeInto(tests, groups) {
const totalTime = tests.map(t => t.time).reduce((a, b) => a + b);
tests[0].sumTime = 0;
tests.map(t => t.time).reduce((a, b, i) => tests[i].sumTime = a + b);
return Array.from(groupBy(tests, t => Math.floor(t.sumTime / (totalTime + 1) * groups)));
}
var groups = groupEqualizeInto(tests, 3);
groups[0][1].map(t => t.name);
groups[1][1].map(t => t.name);
groups[2][1].map(t => t.name);
Keep @SmallTest
out of the grouping:
var groups = groupEqualizeInto(tests.filter(t => t.time >= 1000), 2);
Current configuration:
- < 1s =
@SmallTest
- < 2.5s =
@MediumTest
- >= 2.5s =
@LargeTest
@FlakyTest
unused but possible to configure for better parallelization/repetition implementation.