Try Promise.all on batches of 16
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
1e49241a0d
commit
a6bc1ec256
|
@ -46,8 +46,11 @@ export async function optimizeImages() {
|
|||
const numberOfWorkers = Math.min(cpus().length, 8);
|
||||
const imagePool = new ImagePool(numberOfWorkers);
|
||||
|
||||
const batchSize = 16;
|
||||
|
||||
for (let i = 0; i < imagePaths.length; i += batchSize) {
|
||||
await Promise.all(
|
||||
imagePaths.map(async (imagePath) => {
|
||||
imagePaths.slice(i, i + batchSize).map(async (imagePath) => {
|
||||
const imageStartTime = Date.now();
|
||||
|
||||
const sourcePath = path.join(SOURCE_DIRECTORY, imagePath);
|
||||
|
@ -104,6 +107,7 @@ export async function optimizeImages() {
|
|||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
await imagePool.close();
|
||||
|
||||
|
|
Loading…
Reference in New Issue