-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
scheduler.test.js
31 lines (28 loc) · 1 KB
/
scheduler.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { createScheduler, createWorker } = Tesseract;
let workers = [];
before(async function cb() {
this.timeout(0);
const NUM_WORKERS = 5;
console.log(`Initializing ${NUM_WORKERS} workers`);
workers = await Promise.all(Array(NUM_WORKERS).fill(0).map(async () => {
return await createWorker("eng", 1, OPTIONS);
}));
console.log(`Initialized ${NUM_WORKERS} workers`);
});
describe('scheduler', () => {
describe('should speed up with more workers (running 10 jobs)', () => {
[1, 3, 5].forEach(num => (
it(`support using ${num} workers`, async () => {
const NUM_JOBS = 10;
const scheduler = createScheduler();
workers.slice(0, num).forEach((w) => {
scheduler.addWorker(w);
});
const rets = await Promise.all(Array(NUM_JOBS).fill(0).map((_, idx) => (
scheduler.addJob('recognize', `${IMAGE_PATH}/${idx % 2 === 0 ? 'simple' : 'cosmic'}.png`)
)));
expect(rets.length).to.be(NUM_JOBS);
}).timeout(60000)
));
});
});