-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
58 lines (52 loc) · 2.06 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
56
57
58
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="wasm_exec.js"></script>
<script>
let cmd_queue = [];
for (i = 0; i < 5; i++) {
cmd_queue.push({"file":"/shootout/nbody.wasm", "n":50000000});
cmd_queue.push({"file":"/shootout/binary-tree.wasm", "n":15});
cmd_queue.push({"file":"/shootout/binary-tree-freelist.wasm", "n":15});
cmd_queue.push({"file":"/shootout/fannkuch.wasm", "n":12});
cmd_queue.push({"file":"/shootout/spectral-norm.wasm", "n":5500});
cmd_queue.push({"file":"/shootout/meteor-contest.wasm", "n":2098});
cmd_queue.push({"file":"/shootout/chameneosredux.wasm", "n":6000000});
cmd_queue.push({"file":"/shootout/pidigits.wasm", "n":10000});
}
function next_cmd() {
if (cmd_queue.length < 1)
return;
item = cmd_queue.pop();
run_single(item.file, item.n);
}
let msgs = [];
msgs.push = function(e) {
Array.prototype.push.call(msgs, e);
update_textpane();
}
function update_textpane() {
document.getElementById('wasm').innerHTML = msgs.join('<br>')
}
async function run_single(file, argn) {
const go = new Go();
const result = await WebAssembly.instantiateStreaming(fetch(file), go.importObject);
let old_log = console.log;
console.log = function(line) {
msgs.push(line);
}
go.argv = [file, '-n', argn];
go.run(result.instance);
console.log = old_log;
next_cmd();
}
window.addEventListener('load', function () {
next_cmd();
})
</script>
</head>
<body>
<div id="wasm"></div>
</body>
</html>