-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtest_workers.html
More file actions
23 lines (23 loc) Β· 1007 Bytes
/
test_workers.html
File metadata and controls
23 lines (23 loc) Β· 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<pre id="output"></pre>
<p id="instructions">
Run <code>python -m http.server 2255</code>,
then open <a href="http://localhost:2255/test/test_workers.html">this file</a>.
</p>
<script>
for (const dbg of ["-debug", ""]) {
for (const asm of ["-asm", "-wasm"]) {
const url = `../dist/worker.sql${asm}${dbg}.js`;
const start_time = performance.now();
const worker = new Worker(url);
worker.onmessage = (e) => {
output.textContent += `[${url}] [${(performance.now() - start_time).toFixed(2)}ms] ${JSON.stringify(e.data)}\n\n`;
instructions.style.display = "none";
}
worker.onerror = (e) => {
output.textContent += `[error] [${url}] [${(performance.now() - start_time).toFixed(2)}ms] ${JSON.stringify(e)}\n\n`;
}
worker.postMessage({"action": "open", "id": 0});
worker.postMessage({"action": "close", "id": 0});
}
}
</script>