forked from mikeseven/node-webgl
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathworker.js
More file actions
38 lines (25 loc) · 717 Bytes
/
worker.js
File metadata and controls
38 lines (25 loc) · 717 Bytes
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
32
33
34
35
36
37
38
'use strict'
var tape = require('tape')
var glWorker = require("./util/worker");
tape('worker - serial', async function (t) {
const jobsData = [1, 2, 3];
t.plan(jobsData.length);
const results = [];
for (const data of jobsData) {
const result = await glWorker(data);
results.push(result);
}
for (const [index, data] of jobsData.entries()) {
t.equal(results[index].length, data * data * 4);
}
t.end()
})
tape('worker - parallel', async function (t) {
const jobsData = [1, 2, 3];
t.plan(jobsData.length);
const results = await Promise.all(jobsData.map(e => glWorker(e)));
for (const [index, data] of jobsData.entries()) {
t.equal(results[index].length, data * data * 4);
}
t.end()
})