-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (16 loc) · 731 Bytes
/
index.js
File metadata and controls
24 lines (16 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { simd } from 'wasm-feature-detect';
import { start } from './pkg/rust_fluid.js'
async function run() {
const multithread = await import('./pkg/rust_fluid.js');
await multithread.default();
// Experimentally, performance degrades when # of threads is larger than 12.
// But this naive setting of numThreads should be improved.
const numThreads = Math.min(12, navigator.hardwareConcurrency);
// const numThreads = navigator.hardwareConcurrency;
// const numThreads = 1;
await multithread.initThreadPool(numThreads);
const threadCountElement = document.getElementById('thread-count');
threadCountElement.textContent = `Running with ${numThreads} threads`;
start();
}
run();