Skip to content

Commit e52e390

Browse files
committed
process bsc in batches
1 parent 500e714 commit e52e390

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

tests/docstrings_examples/DocTest.res

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,35 @@ let main = async () => {
325325
->Array.map(f => extractDocFromFile(Path.join(["runtime", f]))->getExamples)
326326
->Array.flat
327327

328+
let batchSize = OS.cpus()->Array.length
329+
328330
let compilationResults =
329-
await modules
330-
->Array.map(async example => {
331-
let id = example.id->String.replaceAll(".", "__")
332-
let rescriptCode = example->getCodeBlocks
333-
let jsCode = await compileTest(~id, ~code=rescriptCode)
334-
(example, (rescriptCode, jsCode))
331+
(await modules
332+
->chunkArray(batchSize)
333+
->Array.map(async arrExample => {
334+
await arrExample
335+
->Array.map(async example => {
336+
let id = example.id->String.replaceAll(".", "__")
337+
let rescriptCode = example->getCodeBlocks
338+
let jsCode = await compileTest(~id, ~code=rescriptCode)
339+
(example, (rescriptCode, jsCode))
340+
})
341+
->Promise.all
335342
})
336-
->Promise.all
343+
->Promise.all)
344+
->Array.flat
345+
346+
// let _ = c > 1
347+
348+
// let compilationResults =
349+
// await modules
350+
// ->Array.map(async example => {
351+
// let id = example.id->String.replaceAll(".", "__")
352+
// let rescriptCode = example->getCodeBlocks
353+
// let jsCode = await compileTest(~id, ~code=rescriptCode)
354+
// (example, (rescriptCode, jsCode))
355+
// })
356+
// ->Promise.all
337357

338358
let (compiled, compilationErrors) = compilationResults->Array.reduce(([], []), (
339359
acc,
@@ -347,7 +367,6 @@ let main = async () => {
347367
(lhs, rhs)
348368
})
349369

350-
let batchSize = OS.cpus()->Array.length
351370
let batches = chunkArray(compiled, batchSize)
352371

353372
let a =

tests/docstrings_examples/DocTest.res.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ async function main() {
361361
return acc.concat([cur]);
362362
}
363363
}).map(f => getExamples(extractDocFromFile(Path.join("runtime", f)))).flat();
364-
let compilationResults = await Promise.all(modules.map(async example => {
364+
let batchSize = Os.cpus().length;
365+
let compilationResults = (await Promise.all(chunkArray(modules, batchSize).map(async arrExample => await Promise.all(arrExample.map(async example => {
365366
let id = example.id.replaceAll(".", "__");
366367
let rescriptCode = getCodeBlocks(example);
367368
let jsCode = await compileTest(id, rescriptCode);
@@ -372,7 +373,7 @@ async function main() {
372373
jsCode
373374
]
374375
];
375-
}));
376+
}))))).flat();
376377
let match = $$Array.reduce(compilationResults, [
377378
[],
378379
[]
@@ -402,7 +403,6 @@ async function main() {
402403
rhs
403404
];
404405
});
405-
let batchSize = Os.cpus().length;
406406
let batches = chunkArray(match[0], batchSize);
407407
let a = await Promise.all(batches.map(async t => $$Array.filterMap(await Promise.all(t.filter(param => !ignoreRuntimeTests.includes(param[0].id)).map(async param => {
408408
let jsCode = param[2];

0 commit comments

Comments
 (0)