This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
55 lines (45 loc) · 1.44 KB
/
index.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module">
import MC from "./dist/index.mjs"
//example part
async function initializeThreads() {
window.MC = MC
MC.initialize(20)
/*
MC.threads.forEach(thread => thread.add(testFunc, testFunc, testFunc))
MC.threads[0].mode = 'fkarr'
console.log(MC.threads[0].pool)
console.log(await MC.run(0, {
message: 'first run 🥸.',
test: 0,
exec_time: 0,
this_will_be_ignored: 'Ok Imma head out' //because it's not defined in parameters
}))
console.log(MC.threads[0].pool)
*/
await MC.test()
function testFunc(message, test, exec_time) {
const start = performance.now()
let value = 0
for (let i = 0; i < 1000000000; i++) value += i
postMessage({
exec_time: performance.now() - start + exec_time,
message: message,
test: test + (value % 10),
this_will_be_ignored_too: 'NOOO'
//'this_will_be_ignored_too' will not been acknowledged by the next worker Q.Q (I'll do that better).
})
}
}
initializeThreads().then()
</script>
</body>
</html>