aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/tests')
-rw-r--r--ext/wasm/tests/opfs/concurrency/test.js7
-rw-r--r--ext/wasm/tests/opfs/concurrency/worker.js9
2 files changed, 9 insertions, 7 deletions
diff --git a/ext/wasm/tests/opfs/concurrency/test.js b/ext/wasm/tests/opfs/concurrency/test.js
index 8b75ea4c7..27bc47b19 100644
--- a/ext/wasm/tests/opfs/concurrency/test.js
+++ b/ext/wasm/tests/opfs/concurrency/test.js
@@ -70,8 +70,7 @@
workers.loadedCount = 0;
workers.onmessage = function(msg){
msg = msg.data;
- const wName = msg.worker;
- const prefix = 'Worker ['+wName+']:';
+ const prefix = 'Worker #'+msg.worker+':';
switch(msg.type){
case 'loaded':
stdout(prefix,"loaded");
@@ -102,7 +101,9 @@
);
for(let i = 0; i < options.workerCount; ++i){
stdout("Launching worker...");
- workers.push(new Worker(workers.uri+(i ? '' : '&unlink-db')));
+ workers.push(new Worker(
+ workers.uri+'&workerId='+(i+1)+(i ? '' : '&unlink-db')
+ ));
}
// Have to delay onmessage assignment until after the loop
// to avoid that early workers get an undue head start.
diff --git a/ext/wasm/tests/opfs/concurrency/worker.js b/ext/wasm/tests/opfs/concurrency/worker.js
index 85a5cf19b..19b0a068e 100644
--- a/ext/wasm/tests/opfs/concurrency/worker.js
+++ b/ext/wasm/tests/opfs/concurrency/worker.js
@@ -2,7 +2,8 @@ importScripts(
(new URL(self.location.href).searchParams).get('sqlite3.dir') + '/sqlite3.js'
);
self.sqlite3InitModule().then(async function(sqlite3){
- const wName = Math.round(Math.random()*10000);
+ const urlArgs = new URL(self.location.href).searchParams;
+ const wName = urlArgs.get('workerId') || Math.round(Math.random()*10000);
const wPost = (type,...payload)=>{
postMessage({type, worker: wName, payload});
};
@@ -18,7 +19,6 @@ self.sqlite3InitModule().then(async function(sqlite3){
};
const dbName = 'concurrency-tester.db';
- const urlArgs = new URL(self.location.href).searchParams;
if(urlArgs.has('unlink-db')){
await sqlite3.opfs.unlink(dbName);
stdout("Unlinked",dbName);
@@ -70,11 +70,12 @@ self.sqlite3InitModule().then(async function(sqlite3){
}
};
if(1){/*use setInterval()*/
- interval.handle = setInterval(async ()=>{
+ setTimeout(async function timer(){
await doWork();
if(interval.error || maxIterations === interval.count){
- clearInterval(interval.handle);
finish();
+ }else{
+ setTimeout(timer, interval.delay);
}
}, interval.delay);
}else{