-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
55 lines (52 loc) · 1.42 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
<input type="button" id="btnGo" value="Run" />
<input type="button" id="btnRt" value="Test WASM" />
<div>
<textarea id="taBoard" cols="80" rows="96" style="display:inline-block;vertical-align:top;white-space:pre" spellcheck=false>
-- The Computer Language Shootout
-- http://shootout.alioth.debian.org/
-- contributed by Mike Pall
local width = 3000
local height, wscale = width, 2/width
local m, limit2 = 50, 4.0
local write, char = io.write, string.char
local iter = 0
write("P4\n", width, " ", height, "\n")
local t1 = os.clock()
for y=0,height-1 do
local Ci = 2*y / height - 1
for xb=0,width-1,8 do
local bits = 0
local xbb = xb+7
local loopend
if xbb < width then loopend = xbb else loopend = width - 1 end
for x=xb,loopend do
bits = bits + bits
local Zr, Zi, Zrq, Ziq = 0.0, 0.0, 0.0, 0.0
local Cr = x * wscale - 1.5
for i=1,m do
local Zri = Zr*Zi
Zr = Zrq - Ziq + Cr
Zi = Zri + Zri + Ci
Zrq = Zr*Zr
Ziq = Zi*Zi
iter = iter + 1
if Zrq + Ziq > limit2 then
bits = bits + 1
break
end
end
end
if xbb >= width then
for x=width,xbb do bits = bits + bits + 1 end
end
write(char(255-bits))
end
end
local t2 = os.clock()
print(t2-t1)
print(iter)
</textarea>
<pre id="prOut" style="display:inline-block;background-color:#eee"></pre>
</div>
<script src="quire.js"></script>
<script src="ui.js"></script>