Skip to content

Commit

Permalink
Fix dumb tasks leak
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Jan 20, 2025
1 parent bb27748 commit b51193a
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions tests/performance/run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const PERF_TESTS_PORT = 8080;
*
* TODO: GitHub actions fails when running the 128th browser. Find out why.
*/
const TEST_ITERATIONS = 50;
const TEST_ITERATIONS = 1;

/**
* After initialization is done, contains the path allowing to run the Chrome
Expand Down Expand Up @@ -82,12 +82,6 @@ let currentBrowser;
*/
const tasks = [];

/**
* Index of the currently ran task in the `tasks` array.
* @see tasks
*/
let nextTaskIndex = 0;

/**
* Store results of the performance tests in two arrays:
* - "current" contains the test results of the current RxPlayer version
Expand Down Expand Up @@ -487,8 +481,8 @@ async function linkRxPlayerBranch({ branchName, remoteGitUrl }) {
* @returns {Promise}
*/
async function startAllTestsOnChrome() {
nextTaskIndex = 0;
CHROME_CMD = await getChromeCmd();
tasks.length = 0;
for (let i = 0; i < TEST_ITERATIONS; i++) {
tasks.push(() => startTestsOnChrome(i % 2 === 0, i + 1, TEST_ITERATIONS));
}
Expand All @@ -498,8 +492,7 @@ async function startAllTestsOnChrome() {
if (tasks.length === 0) {
throw new Error("No task scheduled");
}
nextTaskIndex++;
return tasks[nextTaskIndex - 1]();
return tasks.shift()();
}

/**
Expand All @@ -521,11 +514,11 @@ async function shutdown() {
* @param {Function} onFinished
*/
function startNextTaskOrFinish(onFinished) {
if (tasks[nextTaskIndex] === undefined) {
const nextTask = tasks.shift();
if (nextTask === undefined) {
onFinished();
}
nextTaskIndex++;
return tasks[nextTaskIndex - 1]();
return nextTask();
}

/**
Expand Down

0 comments on commit b51193a

Please sign in to comment.