Skip to content

Commit aadd7cc

Browse files
MaxGraeydcodeIO
authored andcommitted
Update n-body bench results (AssemblyScript#872)
1 parent bd78683 commit aadd7cc

File tree

8 files changed

+154
-123
lines changed

8 files changed

+154
-123
lines changed

examples/n-body/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,17 @@ Benchmark
3131

3232
***Environment:***
3333
- MacBook Pro (Retina, 15-inch, Late 2013)
34-
- macOS 10.14.3
35-
- node.js v11.10.1
36-
- rustc 1.35.0-nightly (a9da8fc9c 2019-03-04)
34+
- macOS 10.14.6
35+
- node.js v12.10.0
36+
- rustc 1.40.0-nightly (37538aa13 2019-09-25)
3737

3838
***Results:***
3939

4040
| Target | Time, ***ms*** | Size, ***KB*** |
4141
|-------------------------|-----------------|----------------|
42-
| **AssemblyScript WASM** | **2921** | **2** |
43-
| AssemblyScript ASMJS | 3807 | 19* |
44-
| JavaScript | 2757 | 5* |
45-
| Rust WASM | 2866 | 20 / 2** |
42+
| **AssemblyScript WASM** | **2821** | **1.6** |
43+
| AssemblyScript ASMJS | 3972 | 19* |
44+
| JavaScript | 2656 | 5* |
45+
| Rust WASM | 2560 | 2 |
4646

4747
___* unminified___
48-
49-
___** after wasm-gc___

examples/n-body/build/optimized.wasm

28 Bytes
Binary file not shown.

examples/n-body/build/optimized.wat

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,59 +17,37 @@
1717
(export "bench" (func $assembly/index/bench))
1818
(export "getBody" (func $assembly/index/getBody))
1919
(start $start)
20-
(func $~lib/rt/stub/__alloc (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
20+
(func $~lib/rt/stub/maybeGrowMemory (; 0 ;) (type $FUNCSIG$vi) (param $0 i32)
21+
(local $1 i32)
2122
(local $2 i32)
22-
(local $3 i32)
23-
(local $4 i32)
24-
(local $5 i32)
25-
local.get $0
26-
i32.const 1073741808
27-
i32.gt_u
28-
if
29-
unreachable
30-
end
31-
global.get $~lib/rt/stub/offset
32-
i32.const 16
33-
i32.add
34-
local.tee $3
3523
local.get $0
36-
i32.const 1
37-
local.get $0
38-
i32.const 1
39-
i32.gt_u
40-
select
41-
i32.add
42-
i32.const 15
43-
i32.add
44-
i32.const -16
45-
i32.and
46-
local.tee $2
4724
memory.size
48-
local.tee $4
25+
local.tee $2
4926
i32.const 16
5027
i32.shl
28+
local.tee $1
5129
i32.gt_u
5230
if
53-
local.get $4
5431
local.get $2
55-
local.get $3
32+
local.get $0
33+
local.get $1
5634
i32.sub
5735
i32.const 65535
5836
i32.add
5937
i32.const -65536
6038
i32.and
6139
i32.const 16
6240
i32.shr_u
63-
local.tee $5
64-
local.get $4
65-
local.get $5
41+
local.tee $1
42+
local.get $2
43+
local.get $1
6644
i32.gt_s
6745
select
6846
memory.grow
6947
i32.const 0
7048
i32.lt_s
7149
if
72-
local.get $5
50+
local.get $1
7351
memory.grow
7452
i32.const 0
7553
i32.lt_s
@@ -78,20 +56,55 @@
7856
end
7957
end
8058
end
81-
local.get $2
59+
local.get $0
8260
global.set $~lib/rt/stub/offset
61+
)
62+
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
63+
(local $2 i32)
64+
(local $3 i32)
65+
(local $4 i32)
66+
local.get $0
67+
i32.const 1073741808
68+
i32.gt_u
69+
if
70+
unreachable
71+
end
72+
global.get $~lib/rt/stub/offset
73+
i32.const 16
74+
i32.add
75+
local.tee $3
76+
local.get $0
77+
i32.const 15
78+
i32.add
79+
i32.const -16
80+
i32.and
81+
local.tee $2
82+
i32.const 16
83+
local.get $2
84+
i32.const 16
85+
i32.gt_u
86+
select
87+
local.tee $4
88+
i32.add
89+
call $~lib/rt/stub/maybeGrowMemory
8390
local.get $3
8491
i32.const 16
8592
i32.sub
8693
local.tee $2
94+
local.get $4
95+
i32.store
96+
local.get $2
97+
i32.const -1
98+
i32.store offset=4
99+
local.get $2
87100
local.get $1
88101
i32.store offset=8
89102
local.get $2
90103
local.get $0
91104
i32.store offset=12
92105
local.get $3
93106
)
94-
(func $assembly/index/NBodySystem#constructor (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
107+
(func $assembly/index/NBodySystem#constructor (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
95108
(local $1 i32)
96109
(local $2 i32)
97110
(local $3 f64)
@@ -174,7 +187,7 @@
174187
i32.store
175188
local.get $1
176189
)
177-
(func $assembly/index/Body#constructor (; 2 ;) (type $FUNCSIG$iddddddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 f64) (param $6 f64) (result i32)
190+
(func $assembly/index/Body#constructor (; 3 ;) (type $FUNCSIG$iddddddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 f64) (param $6 f64) (result i32)
178191
(local $7 i32)
179192
i32.const 56
180193
i32.const 4
@@ -202,7 +215,7 @@
202215
f64.store offset=48
203216
local.get $7
204217
)
205-
(func $~lib/rt/__allocArray (; 3 ;) (type $FUNCSIG$i) (result i32)
218+
(func $~lib/rt/__allocArray (; 4 ;) (type $FUNCSIG$i) (result i32)
206219
(local $0 i32)
207220
(local $1 i32)
208221
i32.const 16
@@ -225,7 +238,7 @@
225238
i32.store offset=12
226239
local.get $0
227240
)
228-
(func $assembly/index/init (; 4 ;) (type $FUNCSIG$v)
241+
(func $assembly/index/init (; 5 ;) (type $FUNCSIG$v)
229242
(local $0 i32)
230243
(local $1 i32)
231244
call $~lib/rt/__allocArray
@@ -285,7 +298,7 @@
285298
call $assembly/index/NBodySystem#constructor
286299
global.set $assembly/index/system
287300
)
288-
(func $assembly/index/NBodySystem#advance (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
301+
(func $assembly/index/NBodySystem#advance (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
289302
(local $1 i32)
290303
(local $2 f64)
291304
(local $3 i32)
@@ -485,7 +498,7 @@
485498
end
486499
end
487500
)
488-
(func $assembly/index/NBodySystem#energy (; 6 ;) (type $FUNCSIG$di) (param $0 i32) (result f64)
501+
(func $assembly/index/NBodySystem#energy (; 7 ;) (type $FUNCSIG$di) (param $0 i32) (result f64)
489502
(local $1 f64)
490503
(local $2 i32)
491504
(local $3 i32)
@@ -613,13 +626,13 @@
613626
end
614627
local.get $1
615628
)
616-
(func $assembly/index/step (; 7 ;) (type $FUNCSIG$d) (result f64)
629+
(func $assembly/index/step (; 8 ;) (type $FUNCSIG$d) (result f64)
617630
global.get $assembly/index/system
618631
call $assembly/index/NBodySystem#advance
619632
global.get $assembly/index/system
620633
call $assembly/index/NBodySystem#energy
621634
)
622-
(func $assembly/index/bench (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
635+
(func $assembly/index/bench (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
623636
(local $1 i32)
624637
block $break|0
625638
loop $loop|0
@@ -638,7 +651,7 @@
638651
unreachable
639652
end
640653
)
641-
(func $assembly/index/getBody (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
654+
(func $assembly/index/getBody (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
642655
(local $1 i32)
643656
local.get $0
644657
global.get $assembly/index/system
@@ -654,17 +667,17 @@
654667
i32.shl
655668
i32.add
656669
i32.load
657-
else
670+
else
658671
i32.const 0
659672
end
660673
)
661-
(func $start (; 10 ;) (type $FUNCSIG$v)
674+
(func $start (; 11 ;) (type $FUNCSIG$v)
662675
i32.const 16
663676
global.set $~lib/rt/stub/startOffset
664-
global.get $~lib/rt/stub/startOffset
677+
i32.const 16
665678
global.set $~lib/rt/stub/offset
666679
)
667-
(func $null (; 11 ;) (type $FUNCSIG$v)
680+
(func $null (; 12 ;) (type $FUNCSIG$v)
668681
nop
669682
)
670683
)

examples/n-body/build/rust.optimized.wasm

100644100755
-49 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)