plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
8f3f4d7
— Peter John
2026-11-09T20:40:10+05:30
Benchmarks: master against simpler-language (compile time, wasm size, run time)
- benchmarks/master_vs_simpler/branch/array.plum +27 -0
- benchmarks/master_vs_simpler/branch/cons.plum +26 -0
- benchmarks/master_vs_simpler/branch/cons_rec.plum +37 -0
- benchmarks/master_vs_simpler/branch/fib.plum +19 -0
- benchmarks/master_vs_simpler/branch/loop.plum +19 -0
- benchmarks/master_vs_simpler/branch/map.plum +27 -0
- benchmarks/master_vs_simpler/branch/particles.plum +30 -0
- benchmarks/master_vs_simpler/branch/str.plum +19 -0
- benchmarks/master_vs_simpler/branch/trig.plum +21 -0
- benchmarks/master_vs_simpler/master/array.plum +27 -0
- benchmarks/master_vs_simpler/master/cons.plum +28 -0
- benchmarks/master_vs_simpler/master/cons_rec.plum +46 -0
- benchmarks/master_vs_simpler/master/fib.plum +21 -0
- benchmarks/master_vs_simpler/master/loop.plum +24 -0
- benchmarks/master_vs_simpler/master/map.plum +27 -0
- benchmarks/master_vs_simpler/master/particles.plum +30 -0
- benchmarks/master_vs_simpler/master/str.plum +19 -0
- benchmarks/master_vs_simpler/master/trig.plum +19 -0
- benchmarks/master_vs_simpler/run.py +312 -0
- benchmarks/scene_trees/run.py +6 -2
- docs/benchmarks/2026-11-09-master-vs-simpler-language.md +140 -0
benchmarks/master_vs_simpler/branch/array.plum
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
fun sumFrom(xs: Slice[Int], i: Int, acc: Int) -> Int = if i >= xs.length() then acc else sumFrom(xs, i + 1, acc + xs.at(i))
|
|
13
|
+
|
|
14
|
+
fun once(n: Int) -> Int =
|
|
15
|
+
xs := Slice[Int]()
|
|
16
|
+
for i := range n
|
|
17
|
+
xs.push(i * 3 % 1001)
|
|
18
|
+
sumFrom(xs, 0, 0)
|
|
19
|
+
|
|
20
|
+
fun reps(k: Int, acc: Int) -> Int = if k == 0 then acc else reps(k - 1, acc + once(1000000))
|
|
21
|
+
|
|
22
|
+
fun main(io: Io) =
|
|
23
|
+
t0 := io.nowMicros()
|
|
24
|
+
r := reps(10, 0)
|
|
25
|
+
t1 := io.nowMicros()
|
|
26
|
+
el := {t1 - t0} / 1000.0
|
|
27
|
+
io.printLn("ms {el} checksum {r}")
|
benchmarks/master_vs_simpler/branch/cons.plum
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
fun build(n: Int, acc: List[Int]) -> List[Int] = if n == 0 then acc else build(n - 1, Cons(head: n, tail: acc))
|
|
13
|
+
|
|
14
|
+
fun once(n: Int) -> Int =
|
|
15
|
+
xs := build(n, Nil)
|
|
16
|
+
ys := xs.map(|x| x * 3 + 1).filter(|x| x % 2 == 0)
|
|
17
|
+
ys.fold(0, |a, x| {a + x} % 1000000007)
|
|
18
|
+
|
|
19
|
+
fun reps(k: Int, acc: Int) -> Int = if k == 0 then acc else reps(k - 1, acc + once(1000000))
|
|
20
|
+
|
|
21
|
+
fun main(io: Io) =
|
|
22
|
+
t0 := io.nowMicros()
|
|
23
|
+
r := reps(5, 0)
|
|
24
|
+
t1 := io.nowMicros()
|
|
25
|
+
el := {t1 - t0} / 1000.0
|
|
26
|
+
io.printLn("ms {el} checksum {r}")
|
benchmarks/master_vs_simpler/branch/cons_rec.plum
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Io
|
|
5
|
+
import std/List
|
|
6
|
+
|
|
7
|
+
fun build(n: Int, acc: List[Int]) -> List[Int] = if n == 0 then acc else build(n - 1, Cons(head: n, tail: acc))
|
|
8
|
+
|
|
9
|
+
fun revOnto(xs: List[Int], acc: List[Int]) -> List[Int] = match xs
|
|
10
|
+
Nil => acc
|
|
11
|
+
Cons(h, t) => revOnto(t, Cons(head: h, tail: acc))
|
|
12
|
+
|
|
13
|
+
fun mapOnto(xs: List[Int], f: fn(Int) -> Int, acc: List[Int]) -> List[Int] = match xs
|
|
14
|
+
Nil => revOnto(acc, Nil)
|
|
15
|
+
Cons(h, t) => mapOnto(t, f, Cons(head: f(h), tail: acc))
|
|
16
|
+
|
|
17
|
+
fun filterOnto(xs: List[Int], keep: fn(Int) -> Bool, acc: List[Int]) -> List[Int] = match xs
|
|
18
|
+
Nil => revOnto(acc, Nil)
|
|
19
|
+
Cons(h, t) => if keep(h) then filterOnto(t, keep, Cons(head: h, tail: acc)) else filterOnto(t, keep, acc)
|
|
20
|
+
|
|
21
|
+
fun foldl(xs: List[Int], acc: Int, f: fn(Int, Int) -> Int) -> Int = match xs
|
|
22
|
+
Nil => acc
|
|
23
|
+
Cons(h, t) => foldl(t, f(acc, h), f)
|
|
24
|
+
|
|
25
|
+
fun once(n: Int) -> Int =
|
|
26
|
+
xs := build(n, Nil)
|
|
27
|
+
ys := filterOnto(mapOnto(xs, |x| x * 3 + 1, Nil), |x| x % 2 == 0, Nil)
|
|
28
|
+
foldl(ys, 0, |a, x| {a + x} % 1000000007)
|
|
29
|
+
|
|
30
|
+
fun reps(k: Int, acc: Int) -> Int = if k == 0 then acc else reps(k - 1, acc + once(1000000))
|
|
31
|
+
|
|
32
|
+
fun main(io: Io) =
|
|
33
|
+
t0 := io.nowMicros()
|
|
34
|
+
r := reps(5, 0)
|
|
35
|
+
t1 := io.nowMicros()
|
|
36
|
+
el := {t1 - t0} / 1000.0
|
|
37
|
+
io.printLn("ms {el} checksum {r}")
|
benchmarks/master_vs_simpler/branch/fib.plum
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
fun fib(n: Int) -> Int = if n < 2 then n else fib(n - 1) + fib(n - 2)
|
|
13
|
+
|
|
14
|
+
fun main(io: Io) =
|
|
15
|
+
t0 := io.nowMicros()
|
|
16
|
+
r := fib(38)
|
|
17
|
+
t1 := io.nowMicros()
|
|
18
|
+
el := {t1 - t0} / 1000.0
|
|
19
|
+
io.printLn("ms {el} checksum {r}")
|
benchmarks/master_vs_simpler/branch/loop.plum
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
fun go(i: Int, n: Int, acc: Int) -> Int = if i >= n then acc else go(i + 1, n, {acc + i * i % 7} % 1000000007)
|
|
13
|
+
|
|
14
|
+
fun main(io: Io) =
|
|
15
|
+
t0 := io.nowMicros()
|
|
16
|
+
r := go(0, 100000000, 0)
|
|
17
|
+
t1 := io.nowMicros()
|
|
18
|
+
el := {t1 - t0} / 1000.0
|
|
19
|
+
io.printLn("ms {el} checksum {r}")
|
benchmarks/master_vs_simpler/branch/map.plum
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
fun look(m: Map[Int, Int], i: Int, n: Int, acc: Int) -> Int = if i >= n then acc else look(m, i + 1, n, acc + m.get(i * 7919 % 1000003).unwrapOr(0) % 13)
|
|
13
|
+
|
|
14
|
+
fun once(n: Int) -> Int =
|
|
15
|
+
m: Map[Int, Int] := Map.empty()
|
|
16
|
+
for i := range n
|
|
17
|
+
m.set(i * 7919 % 1000003, i)
|
|
18
|
+
look(m, 0, n, 0) + m.length()
|
|
19
|
+
|
|
20
|
+
fun reps(k: Int, acc: Int) -> Int = if k == 0 then acc else reps(k - 1, acc + once(200000))
|
|
21
|
+
|
|
22
|
+
fun main(io: Io) =
|
|
23
|
+
t0 := io.nowMicros()
|
|
24
|
+
r := reps(5, 0)
|
|
25
|
+
t1 := io.nowMicros()
|
|
26
|
+
el := {t1 - t0} / 1000.0
|
|
27
|
+
io.printLn("ms {el} checksum {r}")
|
benchmarks/master_vs_simpler/branch/particles.plum
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
struct P(x: Float, y: Float, vx: Float, vy: Float) =
|
|
13
|
+
fun moved(self) -> P =
|
|
14
|
+
nx := self.x + self.vx
|
|
15
|
+
ny := self.y + self.vy
|
|
16
|
+
P(..self, x: nx, y: ny, vx: if nx < 0.0 || nx > 200.0 then -self.vx else self.vx, vy: if ny < 0.0 || ny > 200.0 then -self.vy else self.vy)
|
|
17
|
+
|
|
18
|
+
fun sumFrom(ps: Slice[P], i: Int, acc: Float) -> Float = if i >= ps.length() then acc else sumFrom(ps, i + 1, acc + ps.at(i).x + ps.at(i).y)
|
|
19
|
+
|
|
20
|
+
fun main(io: Io) =
|
|
21
|
+
ps := Slice[P]()
|
|
22
|
+
for i := range 1000
|
|
23
|
+
ps.push(P(x: Float(i % 200), y: Float(i * 7 % 200), vx: Float(i % 5) - 2.0, vy: Float(i % 7) - 3.0))
|
|
24
|
+
t0 := io.nowMicros()
|
|
25
|
+
for t := range 20000
|
|
26
|
+
for i := range ps.length()
|
|
27
|
+
ps.putAt(i, ps.takeAt(i).moved())
|
|
28
|
+
t1 := io.nowMicros()
|
|
29
|
+
el := {t1 - t0} / 1000.0
|
|
30
|
+
io.printLn("ms {el} checksum {Int(sumFrom(ps, 0, 0.0))}")
|
benchmarks/master_vs_simpler/branch/str.plum
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
fun go(i: Int, n: Int, acc: Int) -> Int = if i >= n then acc else go(i + 1, n, acc + "item-{i}-{i % 97}".length())
|
|
13
|
+
|
|
14
|
+
fun main(io: Io) =
|
|
15
|
+
t0 := io.nowMicros()
|
|
16
|
+
total := go(0, 2000000, 0)
|
|
17
|
+
t1 := io.nowMicros()
|
|
18
|
+
el := {t1 - t0} / 1000.0
|
|
19
|
+
io.printLn("ms {el} checksum {total}")
|
benchmarks/master_vs_simpler/branch/trig.plum
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/List
|
|
8
|
+
import std/Slice
|
|
9
|
+
import std/Map
|
|
10
|
+
import std/math
|
|
11
|
+
|
|
12
|
+
fun go(i: Int, n: Int, s: Float) -> Float =
|
|
13
|
+
x := Float(i) * 0.001
|
|
14
|
+
if i >= n then s else go(i + 1, n, s + math.sin(x) * math.cos(x * 0.5) + math.sqrt(x))
|
|
15
|
+
|
|
16
|
+
fun main(io: Io) =
|
|
17
|
+
t0 := io.nowMicros()
|
|
18
|
+
s := go(0, 5000000, 0.0)
|
|
19
|
+
t1 := io.nowMicros()
|
|
20
|
+
el := {t1 - t0} / 1000.0
|
|
21
|
+
io.printLn("ms {el} checksum {Int(s)}")
|
benchmarks/master_vs_simpler/master/array.plum
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/collections/List
|
|
8
|
+
import std/collections/LinkedList
|
|
9
|
+
import std/collections/Map
|
|
10
|
+
import std/math/math
|
|
11
|
+
|
|
12
|
+
fun once(n: Int) -> Int
|
|
13
|
+
xs := List[Int]()
|
|
14
|
+
for i := range n
|
|
15
|
+
xs.push(i * 3 % 1001)
|
|
16
|
+
s := 0
|
|
17
|
+
for i := range xs.length()
|
|
18
|
+
s = s + xs.at(i)
|
|
19
|
+
return s
|
|
20
|
+
|
|
21
|
+
fun main(io: Io)
|
|
22
|
+
t0 := io.nowMicros()
|
|
23
|
+
r := 0
|
|
24
|
+
for k := range 10
|
|
25
|
+
r = r + once(1000000)
|
|
26
|
+
t1 := io.nowMicros()
|
|
27
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {r}")
|
benchmarks/master_vs_simpler/master/cons.plum
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/collections/List
|
|
8
|
+
import std/collections/LinkedList
|
|
9
|
+
import std/collections/Map
|
|
10
|
+
import std/math/math
|
|
11
|
+
|
|
12
|
+
fun build(n: Int, acc: LinkedList[Int]) -> LinkedList[Int]
|
|
13
|
+
if n == 0
|
|
14
|
+
return acc
|
|
15
|
+
return build(n - 1, Cons(head: n, tail: acc))
|
|
16
|
+
|
|
17
|
+
fun once(n: Int) -> Int
|
|
18
|
+
xs := build(n, Nil)
|
|
19
|
+
ys := xs.map(|x| x * 3 + 1).filter(|x| x % 2 == 0)
|
|
20
|
+
return ys.fold(0, |a, x| {a + x} % 1000000007)
|
|
21
|
+
|
|
22
|
+
fun main(io: Io)
|
|
23
|
+
t0 := io.nowMicros()
|
|
24
|
+
r := 0
|
|
25
|
+
for k := range 5
|
|
26
|
+
r = r + once(1000000)
|
|
27
|
+
t1 := io.nowMicros()
|
|
28
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {r}")
|
benchmarks/master_vs_simpler/master/cons_rec.plum
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Io
|
|
5
|
+
import std/collections/LinkedList
|
|
6
|
+
|
|
7
|
+
fun build(n: Int, acc: LinkedList[Int]) -> LinkedList[Int]
|
|
8
|
+
if n == 0
|
|
9
|
+
return acc
|
|
10
|
+
return build(n - 1, Cons(head: n, tail: acc))
|
|
11
|
+
|
|
12
|
+
fun revOnto(xs: LinkedList[Int], acc: LinkedList[Int]) -> LinkedList[Int]
|
|
13
|
+
match xs
|
|
14
|
+
Nil => return acc
|
|
15
|
+
Cons(h, t) => return revOnto(t, Cons(head: h, tail: acc))
|
|
16
|
+
|
|
17
|
+
fun mapOnto(xs: LinkedList[Int], f: fn(Int) -> Int, acc: LinkedList[Int]) -> LinkedList[Int]
|
|
18
|
+
match xs
|
|
19
|
+
Nil => return revOnto(acc, Nil)
|
|
20
|
+
Cons(h, t) => return mapOnto(t, f, Cons(head: f(h), tail: acc))
|
|
21
|
+
|
|
22
|
+
fun filterOnto(xs: LinkedList[Int], keep: fn(Int) -> Bool, acc: LinkedList[Int]) -> LinkedList[Int]
|
|
23
|
+
match xs
|
|
24
|
+
Nil => return revOnto(acc, Nil)
|
|
25
|
+
Cons(h, t) =>
|
|
26
|
+
if keep(h)
|
|
27
|
+
return filterOnto(t, keep, Cons(head: h, tail: acc))
|
|
28
|
+
return filterOnto(t, keep, acc)
|
|
29
|
+
|
|
30
|
+
fun foldl(xs: LinkedList[Int], acc: Int, f: fn(Int, Int) -> Int) -> Int
|
|
31
|
+
match xs
|
|
32
|
+
Nil => return acc
|
|
33
|
+
Cons(h, t) => return foldl(t, f(acc, h), f)
|
|
34
|
+
|
|
35
|
+
fun once(n: Int) -> Int
|
|
36
|
+
xs := build(n, Nil)
|
|
37
|
+
ys := filterOnto(mapOnto(xs, |x| x * 3 + 1, Nil), |x| x % 2 == 0, Nil)
|
|
38
|
+
return foldl(ys, 0, |a, x| {a + x} % 1000000007)
|
|
39
|
+
|
|
40
|
+
fun main(io: Io)
|
|
41
|
+
t0 := io.nowMicros()
|
|
42
|
+
r := 0
|
|
43
|
+
for k := range 5
|
|
44
|
+
r = r + once(1000000)
|
|
45
|
+
t1 := io.nowMicros()
|
|
46
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {r}")
|
benchmarks/master_vs_simpler/master/fib.plum
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/collections/List
|
|
8
|
+
import std/collections/LinkedList
|
|
9
|
+
import std/collections/Map
|
|
10
|
+
import std/math/math
|
|
11
|
+
|
|
12
|
+
fun fib(n: Int) -> Int
|
|
13
|
+
if n < 2
|
|
14
|
+
return n
|
|
15
|
+
return fib(n - 1) + fib(n - 2)
|
|
16
|
+
|
|
17
|
+
fun main(io: Io)
|
|
18
|
+
t0 := io.nowMicros()
|
|
19
|
+
r := fib(38)
|
|
20
|
+
t1 := io.nowMicros()
|
|
21
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {r}")
|
benchmarks/master_vs_simpler/master/loop.plum
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/collections/List
|
|
8
|
+
import std/collections/LinkedList
|
|
9
|
+
import std/collections/Map
|
|
10
|
+
import std/math/math
|
|
11
|
+
|
|
12
|
+
fun work(n: Int) -> Int
|
|
13
|
+
acc := 0
|
|
14
|
+
i := 0
|
|
15
|
+
while i < n
|
|
16
|
+
acc = {acc + i * i % 7} % 1000000007
|
|
17
|
+
i = i + 1
|
|
18
|
+
return acc
|
|
19
|
+
|
|
20
|
+
fun main(io: Io)
|
|
21
|
+
t0 := io.nowMicros()
|
|
22
|
+
r := work(100000000)
|
|
23
|
+
t1 := io.nowMicros()
|
|
24
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {r}")
|
benchmarks/master_vs_simpler/master/map.plum
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/collections/List
|
|
8
|
+
import std/collections/LinkedList
|
|
9
|
+
import std/collections/Map
|
|
10
|
+
import std/math/math
|
|
11
|
+
|
|
12
|
+
fun once(n: Int) -> Int
|
|
13
|
+
m := Map[Int, Int]()
|
|
14
|
+
for i := range n
|
|
15
|
+
m.set(i * 7919 % 1000003, i)
|
|
16
|
+
s := 0
|
|
17
|
+
for i := range n
|
|
18
|
+
s = s + m.get(i * 7919 % 1000003).unwrapOr(0) % 13
|
|
19
|
+
return s + m.length()
|
|
20
|
+
|
|
21
|
+
fun main(io: Io)
|
|
22
|
+
t0 := io.nowMicros()
|
|
23
|
+
r := 0
|
|
24
|
+
for k := range 5
|
|
25
|
+
r = r + once(200000)
|
|
26
|
+
t1 := io.nowMicros()
|
|
27
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {r}")
|
benchmarks/master_vs_simpler/master/particles.plum
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Io
|
|
5
|
+
import std/collections/List
|
|
6
|
+
|
|
7
|
+
struct P(x: Float, y: Float, vx: Float, vy: Float) =
|
|
8
|
+
fun move(&self)
|
|
9
|
+
nx := self.x + self.vx
|
|
10
|
+
ny := self.y + self.vy
|
|
11
|
+
if nx < 0.0 || nx > 200.0
|
|
12
|
+
self.vx = -self.vx
|
|
13
|
+
if ny < 0.0 || ny > 200.0
|
|
14
|
+
self.vy = -self.vy
|
|
15
|
+
self.x = nx
|
|
16
|
+
self.y = ny
|
|
17
|
+
|
|
18
|
+
fun main(io: Io)
|
|
19
|
+
ps := List[P]()
|
|
20
|
+
for i := range 1000
|
|
21
|
+
ps.push(P(x: Float(i % 200), y: Float(i * 7 % 200), vx: Float(i % 5) - 2.0, vy: Float(i % 7) - 3.0))
|
|
22
|
+
t0 := io.nowMicros()
|
|
23
|
+
for t := range 20000
|
|
24
|
+
for i := range ps.length()
|
|
25
|
+
ps.at(i).move()
|
|
26
|
+
t1 := io.nowMicros()
|
|
27
|
+
s := 0.0
|
|
28
|
+
for i := range ps.length()
|
|
29
|
+
s = s + ps.at(i).x + ps.at(i).y
|
|
30
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {Int(s)}")
|
benchmarks/master_vs_simpler/master/str.plum
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/collections/List
|
|
8
|
+
import std/collections/LinkedList
|
|
9
|
+
import std/collections/Map
|
|
10
|
+
import std/math/math
|
|
11
|
+
|
|
12
|
+
fun main(io: Io)
|
|
13
|
+
t0 := io.nowMicros()
|
|
14
|
+
total := 0
|
|
15
|
+
for i := range 2000000
|
|
16
|
+
s := "item-{i}-{i % 97}"
|
|
17
|
+
total = total + s.length()
|
|
18
|
+
t1 := io.nowMicros()
|
|
19
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {total}")
|
benchmarks/master_vs_simpler/master/trig.plum
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import std/Int
|
|
2
|
+
import std/Float
|
|
3
|
+
import std/Str
|
|
4
|
+
import std/Bool
|
|
5
|
+
import std/Option
|
|
6
|
+
import std/Io
|
|
7
|
+
import std/collections/List
|
|
8
|
+
import std/collections/LinkedList
|
|
9
|
+
import std/collections/Map
|
|
10
|
+
import std/math/math
|
|
11
|
+
|
|
12
|
+
fun main(io: Io)
|
|
13
|
+
t0 := io.nowMicros()
|
|
14
|
+
s := 0.0
|
|
15
|
+
for i := range 5000000
|
|
16
|
+
x := Float(i) * 0.001
|
|
17
|
+
s = s + math.sin(x) * math.cos(x * 0.5) + math.sqrt(x)
|
|
18
|
+
t1 := io.nowMicros()
|
|
19
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {Int(s)}")
|
benchmarks/master_vs_simpler/run.py
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Times master against simpler-language on ported programs: compile time, wasm size, run time.
|
|
3
|
+
|
|
4
|
+
usage: python3 benchmarks/master_vs_simpler/run.py --master DIR [--master-plum PATH] [--plum PATH]
|
|
5
|
+
[--runs 5] [--out target/master_vs_simpler]
|
|
6
|
+
[--only fib,loop,...]
|
|
7
|
+
|
|
8
|
+
Run from the root of a simpler-language checkout. DIR is a checkout of master (cd59829 or
|
|
9
|
+
later) with its compiler built; `--master-plum` defaults to DIR/target/release/plum and
|
|
10
|
+
`--plum` to target/release/plum. Each compiler compiles with its own std: master's
|
|
11
|
+
programs from DIR, the branch's from here.
|
|
12
|
+
|
|
13
|
+
No program compiles unchanged on both branches (master needs `return` in a block body and
|
|
14
|
+
rejects `fun f() = value`; the branch needs `= value` and has no `return`), so every
|
|
15
|
+
program is a port: master/X.plum and branch/X.plum run the same algorithm on the same
|
|
16
|
+
data and print the same checksum. The two games are drivers written around each branch's
|
|
17
|
+
own game (master's examples/games/orbitrunner and balloonpop, the branch's
|
|
18
|
+
examples/games/orb_run and kids/balloon_pop): this script copies the game without its
|
|
19
|
+
`main` and tests and appends a headless `main` that steps it a fixed number of ticks with
|
|
20
|
+
inputs that are a function of the seed and tick only.
|
|
21
|
+
|
|
22
|
+
For each program: `plum compile` --runs times on each branch (median ms, wasm bytes),
|
|
23
|
+
`plum build` executables (master; the branch's default, --no-fbip and --no-fusion), then
|
|
24
|
+
--runs rounds, each running every executable once as a fresh process in a rotated order.
|
|
25
|
+
Every program prints `ms <in-program ms, from io.nowMicros> checksum ...`; the run fails if
|
|
26
|
+
the branch's three builds disagree on the rest of the line.
|
|
27
|
+
"""
|
|
28
|
+
import argparse
|
|
29
|
+
import json
|
|
30
|
+
import os
|
|
31
|
+
import re
|
|
32
|
+
import statistics
|
|
33
|
+
import subprocess
|
|
34
|
+
import sys
|
|
35
|
+
import time
|
|
36
|
+
|
|
37
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
38
|
+
MICRO = ["fib", "loop", "array", "map", "cons", "cons_rec", "str", "particles", "trig"]
|
|
39
|
+
ORB_TICKS, ORB_SEEDS = 3000, "[1, 2, 3, 5, 7, 11, 13, 42, 99, 123, 777, 2024, 31337]"
|
|
40
|
+
BP_TICKS, BP_SEEDS = 20000, "[1, 2, 3, 9, 42, 777]"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def strip_main(path, sig):
|
|
44
|
+
"""The game's source without its test blocks and without its `main`."""
|
|
45
|
+
s = open(path).read()
|
|
46
|
+
if '\ntest "' in s:
|
|
47
|
+
s = s[:s.index('\ntest "') + 1]
|
|
48
|
+
if "# --- tests ---" in s:
|
|
49
|
+
s = s[:s.index("# --- tests ---")]
|
|
50
|
+
i = s.index(sig)
|
|
51
|
+
ends = [x for x in (s.find("\nfun ", i + 1), s.find("\n# ", i + 1)) if x >= 0]
|
|
52
|
+
e = min(ends) if ends else len(s)
|
|
53
|
+
return s[:i] + s[e + 1:]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
ORB_MASTER = '''
|
|
57
|
+
fun steerX(seed: Int, t: Int) -> Float
|
|
58
|
+
return Float({{seed * 7 + t / 9} * 2654435761 % 1000003} % 3 - 1)
|
|
59
|
+
|
|
60
|
+
fun steerY(seed: Int, t: Int) -> Float
|
|
61
|
+
return Float({{seed * 13 + t / 13} * 40503 % 1000033} % 3 - 1)
|
|
62
|
+
|
|
63
|
+
fun heldAt(seed: Int, t: Int) -> List[Int]
|
|
64
|
+
keys := List[Int]()
|
|
65
|
+
if steerX(seed, t) < 0.0
|
|
66
|
+
keys.push(Key.Left)
|
|
67
|
+
if steerX(seed, t) > 0.0
|
|
68
|
+
keys.push(Key.Right)
|
|
69
|
+
if steerY(seed, t) < 0.0
|
|
70
|
+
keys.push(Key.Up)
|
|
71
|
+
if steerY(seed, t) > 0.0
|
|
72
|
+
keys.push(Key.Down)
|
|
73
|
+
return keys
|
|
74
|
+
|
|
75
|
+
fun inputAt(seed: Int, t: Int, over: Bool) -> Input
|
|
76
|
+
now := heldAt(seed, t)
|
|
77
|
+
before := List[Int]()
|
|
78
|
+
if t > 0
|
|
79
|
+
before = heldAt(seed, t - 1)
|
|
80
|
+
events := List[InputEvent]()
|
|
81
|
+
px := Float({t * 37} % 800)
|
|
82
|
+
py := Float({t * 53} % 600)
|
|
83
|
+
events.push(PointerMove(x: px, y: py))
|
|
84
|
+
for k := range [Key.Left, Key.Right, Key.Up, Key.Down]
|
|
85
|
+
if now.contains(k) && !before.contains(k)
|
|
86
|
+
events.push(KeyDown(key: k))
|
|
87
|
+
if !now.contains(k) && before.contains(k)
|
|
88
|
+
events.push(KeyUp(key: k))
|
|
89
|
+
if over && t % 150 == 0
|
|
90
|
+
events.push(KeyDown(key: Key.Enter))
|
|
91
|
+
inp := Input(held: Held(mouse: false, keys: now), events: events, pos: Vec2(x: px, y: py), wheel: 0.0)
|
|
92
|
+
return inp.sized(800.0, 600.0)
|
|
93
|
+
|
|
94
|
+
fun main(io: Io)
|
|
95
|
+
t0 := io.nowMicros()
|
|
96
|
+
check := 0
|
|
97
|
+
overs := 0
|
|
98
|
+
scores := 0
|
|
99
|
+
mines := 0
|
|
100
|
+
for seed := range SEEDS
|
|
101
|
+
g := OrbitRunner.headless(seed)
|
|
102
|
+
wasOver := false
|
|
103
|
+
for t := range TICKS
|
|
104
|
+
g.update(io, inputAt(seed, t, g.world.run.over), 1.0 / 60.0)
|
|
105
|
+
r := g.world.run
|
|
106
|
+
if r.over && !wasOver
|
|
107
|
+
overs = overs + 1
|
|
108
|
+
scores = scores + r.score
|
|
109
|
+
wasOver = r.over
|
|
110
|
+
check = {check * 31 + r.score + r.lives} % 1000000007
|
|
111
|
+
mines = mines + g.world.mineList.length()
|
|
112
|
+
t1 := io.nowMicros()
|
|
113
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {check} overs {overs} scoreAtOver {scores} minesAtEnd {mines}")
|
|
114
|
+
'''
|
|
115
|
+
|
|
116
|
+
ORB_BRANCH = '''
|
|
117
|
+
fun steerX(seed: Int, t: Int) -> Float = Float({{seed * 7 + t / 9} * 2654435761 % 1000003} % 3 - 1)
|
|
118
|
+
|
|
119
|
+
fun steerY(seed: Int, t: Int) -> Float = Float({{seed * 13 + t / 13} * 40503 % 1000033} % 3 - 1)
|
|
120
|
+
|
|
121
|
+
fun heldAt(seed: Int, t: Int) -> Slice[Int] =
|
|
122
|
+
keys := Slice[Int]()
|
|
123
|
+
if steerX(seed, t) < 0.0
|
|
124
|
+
keys.push(Key.Left)
|
|
125
|
+
if steerX(seed, t) > 0.0
|
|
126
|
+
keys.push(Key.Right)
|
|
127
|
+
if steerY(seed, t) < 0.0
|
|
128
|
+
keys.push(Key.Up)
|
|
129
|
+
if steerY(seed, t) > 0.0
|
|
130
|
+
keys.push(Key.Down)
|
|
131
|
+
keys
|
|
132
|
+
|
|
133
|
+
fun inputAt(seed: Int, t: Int, over: Bool) -> Input =
|
|
134
|
+
now := heldAt(seed, t)
|
|
135
|
+
before := if t == 0 then Slice[Int]() else heldAt(seed, t - 1)
|
|
136
|
+
events := Slice[InputEvent]()
|
|
137
|
+
px := Float({t * 37} % 800)
|
|
138
|
+
py := Float({t * 53} % 600)
|
|
139
|
+
events.push(PointerMove(x: px, y: py))
|
|
140
|
+
for k := range [Key.Left, Key.Right, Key.Up, Key.Down]
|
|
141
|
+
if now.contains(k) && !before.contains(k)
|
|
142
|
+
events.push(KeyDown(key: k))
|
|
143
|
+
if !now.contains(k) && before.contains(k)
|
|
144
|
+
events.push(KeyUp(key: k))
|
|
145
|
+
if over && t % 150 == 0
|
|
146
|
+
events.push(KeyDown(key: Key.Enter))
|
|
147
|
+
Input(held: Held(mouse: false, keys: now), events: events, pos: Vec2(x: px, y: py), wheel: 0.0)
|
|
148
|
+
|
|
149
|
+
struct Tally(check: Int, overs: Int, scores: Int, mines: Int)
|
|
150
|
+
|
|
151
|
+
fun run(io: Io, seed: Int, g: Game[State, Msg], t: Int, was: Bool, acc: Tally) -> Tally =
|
|
152
|
+
if t >= TICKS
|
|
153
|
+
Tally(..acc, mines: acc.mines + g.state().mines)
|
|
154
|
+
else
|
|
155
|
+
n := g.step(io, inputAt(seed, t, g.state().over), 1.0 / 60.0, Vec2(x: 800.0, y: 600.0))
|
|
156
|
+
r := n.state()
|
|
157
|
+
fresh := r.over && !was
|
|
158
|
+
a := Tally(check: {acc.check * 31 + r.score + r.lives} % 1000000007, overs: if fresh then acc.overs + 1 else acc.overs, scores: if fresh then acc.scores + r.score else acc.scores, mines: acc.mines)
|
|
159
|
+
run(io, seed, n, t + 1, r.over, a)
|
|
160
|
+
|
|
161
|
+
fun main(io: Io) =
|
|
162
|
+
t0 := io.nowMicros()
|
|
163
|
+
enter := Input(held: Held.none(), events: [KeyDown(key: Key.Enter)].toSlice(), pos: Vec2(x: 0.0, y: 0.0), wheel: 0.0)
|
|
164
|
+
tally := SEEDS.fold(Tally(check: 0, overs: 0, scores: 0, mines: 0), |acc, seed|
|
|
165
|
+
g: Game[State, Msg] := Game.start(gameTree(), State.create(seed, Texture(id: -1), Sounds.silent()))
|
|
166
|
+
run(io, seed, g.step(io, enter, 1.0 / 60.0, Vec2(x: 800.0, y: 600.0)), 0, false, acc))
|
|
167
|
+
t1 := io.nowMicros()
|
|
168
|
+
el := {t1 - t0} / 1000.0
|
|
169
|
+
io.printLn("ms {el} checksum {tally.check} overs {tally.overs} scoreAtOver {tally.scores} minesAtEnd {tally.mines}")
|
|
170
|
+
'''
|
|
171
|
+
|
|
172
|
+
BP_MASTER = '''
|
|
173
|
+
fun main(io: Io)
|
|
174
|
+
t0 := io.nowMicros()
|
|
175
|
+
check := 0
|
|
176
|
+
pops := 0
|
|
177
|
+
for seed := range SEEDS
|
|
178
|
+
g := BalloonPop.headless(seed)
|
|
179
|
+
for t := range TICKS
|
|
180
|
+
events := List[InputEvent]()
|
|
181
|
+
events.push(PointerDown(x: Float({t * 97} % 800), y: Float({t * 61} % 600)))
|
|
182
|
+
inp := Input(held: Held.none(), events: events, pos: Vec2(x: 0.0, y: 0.0), wheel: 0.0)
|
|
183
|
+
g.update(io, inp.sized(800.0, 600.0), 1.0 / 60.0)
|
|
184
|
+
check = {check * 31 + g.field.run.pops} % 1000000007
|
|
185
|
+
pops = pops + g.field.run.pops
|
|
186
|
+
t1 := io.nowMicros()
|
|
187
|
+
io.printLn("ms {Float(t1 - t0) / 1000.0} checksum {check} pops {pops}")
|
|
188
|
+
'''
|
|
189
|
+
|
|
190
|
+
BP_BRANCH = '''
|
|
191
|
+
struct Tally(check: Int, pops: Int)
|
|
192
|
+
|
|
193
|
+
fun run(io: Io, g: Game[State, Msg], t: Int, acc: Tally) -> Tally =
|
|
194
|
+
if t >= TICKS
|
|
195
|
+
Tally(..acc, pops: acc.pops + g.state().pops)
|
|
196
|
+
else
|
|
197
|
+
events := Slice[InputEvent]()
|
|
198
|
+
events.push(PointerDown(x: Float({t * 97} % 800), y: Float({t * 61} % 600)))
|
|
199
|
+
inp := Input(held: Held.none(), events: events, pos: Vec2(x: 0.0, y: 0.0), wheel: 0.0)
|
|
200
|
+
n := g.step(io, inp, 1.0 / 60.0, Vec2(x: 800.0, y: 600.0))
|
|
201
|
+
run(io, n, t + 1, Tally(..acc, check: {acc.check * 31 + n.state().pops} % 1000000007))
|
|
202
|
+
|
|
203
|
+
fun main(io: Io) =
|
|
204
|
+
t0 := io.nowMicros()
|
|
205
|
+
tally := SEEDS.fold(Tally(check: 0, pops: 0), |acc, seed|
|
|
206
|
+
play := SkyScreen.start(State.start(seed, Sound.Silent, Sound.Silent))
|
|
207
|
+
g: Game[State, Msg] := Game.start(play.tree, play.state)
|
|
208
|
+
run(io, g, 0, acc))
|
|
209
|
+
t1 := io.nowMicros()
|
|
210
|
+
el := {t1 - t0} / 1000.0
|
|
211
|
+
io.printLn("ms {el} checksum {tally.check} pops {tally.pops}")
|
|
212
|
+
'''
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def write_games(master, out):
|
|
216
|
+
"""Writes the four game drivers into `out` and returns their (name, master, branch) paths."""
|
|
217
|
+
games = [
|
|
218
|
+
("orb_run", master + "/examples/games/orbitrunner/OrbitRunner.plum", "fun main(io: Io) -> OrbitRunner",
|
|
219
|
+
ORB_MASTER, "examples/games/orb_run.plum", "fun main(io: Io) -> Game[State, Msg]", ORB_BRANCH, ORB_TICKS, ORB_SEEDS),
|
|
220
|
+
("balloon_pop", master + "/examples/games/balloonpop/BalloonPop.plum", "fun main(io: Io) -> BalloonPop",
|
|
221
|
+
BP_MASTER, "examples/games/kids/balloon_pop.plum", "fun main(io: Io) -> Game[State, Msg]", BP_BRANCH, BP_TICKS, BP_SEEDS),
|
|
222
|
+
]
|
|
223
|
+
progs = []
|
|
224
|
+
for name, msrc, msig, mdrv, bsrc, bsig, bdrv, ticks, seeds in games:
|
|
225
|
+
mp, bp = f"{out}/{name}_master.plum", f"{out}/{name}_branch.plum"
|
|
226
|
+
for path, src, sig, drv in ((mp, msrc, msig, mdrv), (bp, bsrc, bsig, bdrv)):
|
|
227
|
+
body = drv.replace("SEEDS", seeds).replace("TICKS", str(ticks))
|
|
228
|
+
open(path, "w").write(strip_main(src, sig) + body)
|
|
229
|
+
progs.append((name, mp, bp))
|
|
230
|
+
return progs
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def fmt(x):
|
|
234
|
+
return f"{x:.0f}" if x >= 10 else f"{x:.1f}"
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def main():
|
|
238
|
+
ap = argparse.ArgumentParser()
|
|
239
|
+
ap.add_argument("--master", required=True)
|
|
240
|
+
ap.add_argument("--master-plum")
|
|
241
|
+
ap.add_argument("--plum", default="target/release/plum")
|
|
242
|
+
ap.add_argument("--runs", type=int, default=5)
|
|
243
|
+
ap.add_argument("--out", default="target/master_vs_simpler")
|
|
244
|
+
ap.add_argument("--only")
|
|
245
|
+
a = ap.parse_args()
|
|
246
|
+
mroot, broot = os.path.abspath(a.master), os.getcwd()
|
|
247
|
+
mplum = os.path.abspath(a.master_plum) if a.master_plum else mroot + "/target/release/plum"
|
|
248
|
+
bplum = os.path.abspath(a.plum)
|
|
249
|
+
out = os.path.abspath(a.out)
|
|
250
|
+
os.makedirs(out, exist_ok=True)
|
|
251
|
+
progs = [(n, f"{HERE}/master/{n}.plum", f"{HERE}/branch/{n}.plum") for n in MICRO] + write_games(mroot, out)
|
|
252
|
+
if a.only:
|
|
253
|
+
keep = a.only.split(",")
|
|
254
|
+
progs = [p for p in progs if p[0] in keep]
|
|
255
|
+
vers = [("master", mplum, mroot, []), ("branch", bplum, broot, []),
|
|
256
|
+
("branch --no-fbip", bplum, broot, ["--no-fbip"]), ("branch --no-fusion", bplum, broot, ["--no-fusion"])]
|
|
257
|
+
names = [v[0] for v in vers]
|
|
258
|
+
res = {}
|
|
259
|
+
for name, msrc, bsrc in progs:
|
|
260
|
+
r = res.setdefault(name, {"compile": {}, "size": {}, "run": {}, "line": {}})
|
|
261
|
+
for v, plum, root, _ in vers[:2]:
|
|
262
|
+
src, wasm = (msrc if v == "master" else bsrc), f"{out}/{name}.{v}.wasm"
|
|
263
|
+
ts = []
|
|
264
|
+
for _ in range(a.runs):
|
|
265
|
+
t = time.perf_counter()
|
|
266
|
+
subprocess.run([plum, "compile", src, "-o", wasm], cwd=root, check=True, capture_output=True)
|
|
267
|
+
ts.append((time.perf_counter() - t) * 1000)
|
|
268
|
+
r["compile"][v], r["size"][v] = ts, os.path.getsize(wasm)
|
|
269
|
+
exes = {}
|
|
270
|
+
for v, plum, root, flags in vers:
|
|
271
|
+
exes[v] = f"{out}/{name}." + v.replace(" --", "_").replace("-", "_")
|
|
272
|
+
subprocess.run([plum, "build", *flags, msrc if v == "master" else bsrc, "-o", exes[v]],
|
|
273
|
+
cwd=root, check=True, capture_output=True)
|
|
274
|
+
for k in range(a.runs):
|
|
275
|
+
for v in names[k % len(names):] + names[:k % len(names)]:
|
|
276
|
+
p = subprocess.run([exes[v]], cwd=out, capture_output=True, text=True)
|
|
277
|
+
m = re.search(r"ms (\S+) (checksum .*)", p.stdout)
|
|
278
|
+
if p.returncode != 0 or not m:
|
|
279
|
+
sys.exit(f"{name} {v} failed: {p.stdout[-500:]} {p.stderr[-2000:]}")
|
|
280
|
+
r["run"].setdefault(v, []).append(float(m.group(1)))
|
|
281
|
+
r["line"].setdefault(v, set()).add(m.group(2).strip())
|
|
282
|
+
print(f"{name}: round {k + 1} done", file=sys.stderr)
|
|
283
|
+
lines = {v: sorted(r["line"][v]) for v in names}
|
|
284
|
+
if len({tuple(lines[v]) for v in names[1:]}) != 1 or len(lines["branch"]) != 1:
|
|
285
|
+
sys.exit(f"{name}: the branch's builds disagree: {lines}")
|
|
286
|
+
r["line"] = lines
|
|
287
|
+
json.dump(res, open(f"{out}/results.json", "w"), indent=1)
|
|
288
|
+
med = statistics.median
|
|
289
|
+
print("| program | master | branch | branch --no-fbip | branch --no-fusion | branch / master |")
|
|
290
|
+
print("|---|---|---|---|---|---|")
|
|
291
|
+
for name, *_ in progs:
|
|
292
|
+
r = res[name]
|
|
293
|
+
cells = [f"{fmt(med(r['run'][v]))} ({fmt(min(r['run'][v]))}-{fmt(max(r['run'][v]))})" for v in names]
|
|
294
|
+
print(f"| {name} | " + " | ".join(cells) + f" | {med(r['run']['branch']) / med(r['run']['master']):.2f}x |")
|
|
295
|
+
print()
|
|
296
|
+
print("| program | master compile ms | branch compile ms | ratio | master wasm bytes | branch wasm bytes | ratio |")
|
|
297
|
+
print("|---|---|---|---|---|---|---|")
|
|
298
|
+
for name, *_ in progs:
|
|
299
|
+
r = res[name]
|
|
300
|
+
mc, bc = med(r["compile"]["master"]), med(r["compile"]["branch"])
|
|
301
|
+
ms, bs = r["size"]["master"], r["size"]["branch"]
|
|
302
|
+
print(f"| {name} | {fmt(mc)} | {fmt(bc)} | {bc / mc:.2f}x | {ms} | {bs} | {bs / ms:.2f}x |")
|
|
303
|
+
print()
|
|
304
|
+
print("| program | master prints | branch prints (all three builds) |")
|
|
305
|
+
print("|---|---|---|")
|
|
306
|
+
for name, *_ in progs:
|
|
307
|
+
r = res[name]
|
|
308
|
+
print(f"| {name} | {'; '.join(r['line']['master'])} | {'; '.join(r['line']['branch'])} |")
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
if __name__ == "__main__":
|
|
312
|
+
main()
|
benchmarks/scene_trees/run.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
usage: python3 benchmarks/scene_trees/run.py --master DIR [--runs 5] [--sizes 100,1000,10000]
|
|
5
5
|
[--workloads 1,...,9] [--out target/scene_trees]
|
|
6
|
+
[--plum target/debug/plum] [--master-plum DIR/target/debug/plum]
|
|
6
7
|
|
|
7
8
|
Run from the repository root of this branch, after `cargo build -p plum-cli`. `--master` is
|
|
8
9
|
a checkout of master (e0ccfc7 or later) with its compiler built (`cargo build -p plum-cli`
|
|
@@ -64,9 +65,12 @@ def main():
|
|
|
64
65
|
ap.add_argument("--sizes", default="100,1000,10000")
|
|
65
66
|
ap.add_argument("--workloads", default="1,2,3,4,5,6,7,8,9")
|
|
66
67
|
ap.add_argument("--out", default="target/scene_trees")
|
|
68
|
+
ap.add_argument("--plum", default="target/debug/plum", help="this branch's compiler")
|
|
69
|
+
ap.add_argument("--master-plum", help="master's compiler (default: DIR/target/debug/plum)")
|
|
67
70
|
args = ap.parse_args()
|
|
68
71
|
master = os.path.abspath(args.master)
|
|
69
|
-
mplum = os.path.join(master, "target/debug/plum")
|
|
72
|
+
mplum = os.path.abspath(args.master_plum) if args.master_plum else os.path.join(master, "target/debug/plum")
|
|
73
|
+
plum = os.path.abspath(args.plum)
|
|
70
74
|
out = os.path.abspath(args.out)
|
|
71
75
|
os.makedirs(out, exist_ok=True)
|
|
72
76
|
exes = {}
|
|
@@ -77,7 +81,7 @@ def main():
|
|
|
77
81
|
build(mplum, os.path.join(HERE, "master/game_enum_tree_kept.plum"), exes["enum_tree"], [], master, master)
|
|
78
82
|
for name, flags in BRANCH:
|
|
79
83
|
exes[name] = os.path.join(out, "b" + "".join(flags).replace("-", "_"))
|
|
80
|
-
build(
|
|
84
|
+
build(plum, os.path.join(HERE, "scene_tree.plum"), exes[name], flags, ".")
|
|
81
85
|
versions = MASTER + [b for b, _ in BRANCH]
|
|
82
86
|
sizes = [int(x) for x in args.sizes.split(",")]
|
|
83
87
|
workloads = [int(x) for x in args.workloads.split(",")]
|
docs/benchmarks/2026-11-09-master-vs-simpler-language.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# master against simpler-language: compile time, wasm size and run time
|
|
2
|
+
|
|
3
|
+
Taken 2026-11-09 on an Apple M3 Pro (18 GB), macOS 26.6.2. Master at `cd59829` (a detached worktree), simpler-language at `ad2cf07` (the scene-tree harness got two path options in this change). Both compilers built with `cargo build --release -p plum-cli`. Every run time is the median of 5 fresh processes, with the range in brackets, in ms. Runs went back to back, one benchmark at a time, on an otherwise idle machine (load average 1.6 to 1.8 during the port runs; it was falling from about 5 at the start of the scene-tree run, left over from the builds).
|
|
4
|
+
|
|
5
|
+
"branch" below means simpler-language.
|
|
6
|
+
|
|
7
|
+
## Short answer
|
|
8
|
+
|
|
9
|
+
- **Same source on both: none.** No program compiles unchanged on both branches, so every number here is from a port (see [Method](#method)). The ports print the same checksums on both, except Orb Run, where one of 13 seeds diverges late (see [the games](#games-headless-ported-drivers)).
|
|
10
|
+
- **The compiler is much slower on the branch for real programs.** Compiling a game takes 5 times as long (3.3 s against 0.65 s for Orb Run, 2.4 s against 0.48 s for Balloon Pop), and the wasm is twice as big. On small programs it's 3 to 40% slower, with a fixed 5 KB more wasm.
|
|
11
|
+
- **The branch's games run slower.** A headless tick costs 1.4 times as much in Orb Run and 3.1 times as much in Balloon Pop.
|
|
12
|
+
- **The branch's persistent scene tree is the fastest tree on most workloads.** It beats master's persistent tree (`game_enum_tree`) by 2 to 3 times, and master's mutable trees on everything except step (17% slower than `std/game`) and eager transforms (2% slower).
|
|
13
|
+
- **Micro workloads are mostly level.** The exceptions: master's `LinkedList` std is 27 times slower than the branch's `List`; the branch is 12 to 24% slower on deep recursion (`fib`), float math, and struct updates.
|
|
14
|
+
- **`--no-fbip` changes nothing measurable anywhere.** `--no-fusion` changes only one program: the std list pipeline, which goes from 137 to 997 ms. Master has neither flag.
|
|
15
|
+
|
|
16
|
+
## Method
|
|
17
|
+
|
|
18
|
+
**Why there is no same-source comparison.** Master's functions need a block body with `return`, and it rejects `fun f() = value`. The branch needs `fun f() = value` and has no `return`. So every function that returns a value is a parse error on one branch or the other, and `main` is too: it's `fun main(io: Io)` with a block on master and `fun main(io: Io) =` on the branch. To check, every `.plum` file in both branches' `examples/`, `tests/` and `compiler/game/web-test/fixtures/` (74 files) was compiled with both compilers. Each compiled only with its own branch's compiler. The std libraries also differ in names: master's `List` is the growable array and `LinkedList` the cons list, while the branch's `Slice` is the array and `List` the cons list.
|
|
19
|
+
|
|
20
|
+
So:
|
|
21
|
+
|
|
22
|
+
1. **Micro workloads** are ports. Each one is the same algorithm on the same data, written once per branch in that branch's idiom. Master uses `while` and assigns to locals and fields. The branch uses tail recursion and spreads. Each port prints the same checksum on both branches. The sources are in `benchmarks/master_vs_simpler/{master,branch}/`.
|
|
23
|
+
2. **Scene trees** use the existing harness, `benchmarks/scene_trees/run.py` (method in [2026-11-08-scene-trees-branch.md](2026-11-08-scene-trees-branch.md)). It runs master's three trees (`std/game`, `std/game_tree`, `std/game_enum_tree`) against the branch's `std/game/scene` tree. These are different code, but they build the same scene from the same random numbers and print the same checksums.
|
|
24
|
+
3. **Games** use headless drivers, which are also ports. `benchmarks/master_vs_simpler/run.py` takes each branch's own game (master's `examples/games/orbitrunner` and `balloonpop`, the branch's `examples/games/orb_run` and `kids/balloon_pop`). It strips the game's `main` and tests and appends a `main` that steps the game for a fixed number of ticks. The inputs depend only on the seed and the tick. Only the update runs, not the drawing, which needs the browser host on both branches.
|
|
25
|
+
|
|
26
|
+
**What is timed.** Run time is measured inside the program with `io.nowMicros()`, and covers the workload only, not startup or building the input. Each program runs from an executable made by `plum build` (the wasm under wasmtime), and each round runs every executable once, in rotated order. Compile time is the wall time of `plum compile` (source to wasm, no native step), the median of 5 runs. The wasm size is the size of that output. Each compiler compiles with its own std.
|
|
27
|
+
|
|
28
|
+
**The web-test stress fixtures** (`compiler/game/web-test/fixtures/stress*.plum`) are left out. They don't compile across branches, the two branches' versions are different programs, and they only run under the browser harness.
|
|
29
|
+
|
|
30
|
+
## Micro workloads (ports, same checksums)
|
|
31
|
+
|
|
32
|
+
| program | what it does | master | branch | branch --no-fbip | branch --no-fusion | branch / master |
|
|
33
|
+
|---|---|---|---|---|---|---|
|
|
34
|
+
| fib | naive `fib(38)` | 138 (138-150) | 155 (150-185) | 150 (149-163) | 153 (150-161) | **1.12x** |
|
|
35
|
+
| loop | 10^8 iterations of integer arithmetic (master `while`, branch a self tail call) | 272 (272-289) | 272 (272-289) | 272 (272-285) | 272 (272-289) | 1.00x |
|
|
36
|
+
| array | push 10^6 Ints onto a growable array and sum them by index, 10 times (master `List`, branch `Slice`) | 110 (110-124) | 105 (105-117) | 105 (105-119) | 105 (105-116) | 0.96x |
|
|
37
|
+
| map | 200,000 `Map[Int, Int]` sets and gets, 5 times | 173 (172-188) | 165 (164-176) | 165 (165-179) | 165 (164-177) | 0.95x |
|
|
38
|
+
| cons | build a 10^6 cons list, then std `map`, `filter`, `fold`, 5 times (master `LinkedList`, branch `List`) | 3779 (3775-3783) | 137 (136-147) | 137 (136-149) | 997 (996-1010) | **0.04x** |
|
|
39
|
+
| cons_rec | the same with hand-written recursive `mapOnto`, `filterOnto` and `foldl` (the same code on both, apart from syntax) | 1852 (1846-1862) | 1834 (1828-1843) | 1832 (1826-1839) | 1832 (1828-1895) | 0.99x |
|
|
40
|
+
| str | 2×10^6 interpolated strings, summing their lengths | 737 (736-760) | 727 (719-736) | 732 (722-749) | 731 (728-741) | 0.99x |
|
|
41
|
+
| particles | 1,000 4-field structs, 20,000 steps of move and bounce (master assigns the fields in a `&self` method, branch `ps.putAt(i, ps.takeAt(i).moved())` with a spread) | 166 (164-180) | 207 (206-216) | 207 (206-218) | 205 (204-216) | **1.24x** |
|
|
42
|
+
| trig | 5×10^6 of `sin(x) * cos(x / 2) + sqrt(x)` with each branch's std/math | 194 (191-208) | 226 (221-234) | 220 (217-241) | 226 (219-232) | **1.17x** |
|
|
43
|
+
|
|
44
|
+
The first round of each program was up to 10% slower than the rest, in every version, so the medians are from warm runs.
|
|
45
|
+
|
|
46
|
+
## Scene trees (different code, same scene, same checksums)
|
|
47
|
+
|
|
48
|
+
`benchmarks/scene_trees/run.py --master <master worktree> --master-plum <its release plum> --plum target/release/plum`. Columns 3 to 5 are master's three trees, built with master's compiler and std. Columns 6 to 8 are the branch's `benchmarks/scene_trees/scene_tree.plum`. Master's programs time themselves with `io.nowMicros()`. The branch's program times itself with the whole-ms clock, so its N = 100 cells are near the clock's resolution. Every cell's checksum agreed across all six versions on every run.
|
|
49
|
+
|
|
50
|
+
| workload | N | master std/game | master std/game_tree | master enum tree | branch | branch --no-fbip | branch --no-fusion | branch / std/game | branch / enum tree |
|
|
51
|
+
|---|---|---|---|---|---|---|---|---|---|
|
|
52
|
+
| step | 1000 | 17 (17-18) | 45 (44-45) | 64 (64-65) | 22 (22-23) | 22 (21-22) | 22 (22-22) | 1.29x | 0.34x |
|
|
53
|
+
| step | 10000 | 167 (166-169) | 412 (407-429) | 622 (622-628) | 196 (196-198) | 197 (196-199) | 196 (196-199) | **1.17x** | 0.31x |
|
|
54
|
+
| churn | 1000 | 25 (25-25) | 49 (49-50) | 86 (85-86) | 40 (40-40) | 40 (40-41) | 40 (40-41) | **1.60x** | 0.47x |
|
|
55
|
+
| churn | 10000 | 821 (820-823) | 705 (684-714) | 857 (855-865) | 376 (375-378) | 376 (376-377) | 377 (375-377) | 0.46x | 0.44x |
|
|
56
|
+
| draw | 1000 | 148 (148-149) | 151 (151-153) | 132 (131-132) | 74 (74-77) | 76 (74-78) | 76 (75-77) | 0.50x | 0.56x |
|
|
57
|
+
| draw | 10000 | 1472 (1468-1475) | 1507 (1502-1518) | 1290 (1287-1294) | 744 (732-744) | 754 (742-764) | 757 (739-760) | 0.51x | 0.58x |
|
|
58
|
+
| hit | 1000 | 120 (120-122) | 121 (121-123) | 119 (119-121) | 58 (57-58) | 57 (57-58) | 58 (57-58) | 0.48x | 0.49x |
|
|
59
|
+
| hit | 10000 | 1010 (1003-1021) | 1028 (1022-1034) | 1003 (998-1006) | 486 (485-490) | 486 (485-489) | 485 (484-489) | 0.48x | 0.48x |
|
|
60
|
+
| step, no transforms | 1000 | 17 (17-17) | 39 (39-40) | 52 (52-53) | 17 (16-17) | 17 (17-17) | 17 (17-17) | 1.00x | 0.33x |
|
|
61
|
+
| step, no transforms | 10000 | 167 (167-170) | 378 (377-385) | 517 (514-520) | 153 (153-154) | 154 (154-155) | 154 (153-154) | 0.92x | 0.30x |
|
|
62
|
+
| step, eager transforms | 1000 | 124 (123-125) | 163 (163-165) | 171 (171-172) | 127 (126-128) | 127 (126-128) | 127 (126-128) | 1.02x | 0.74x |
|
|
63
|
+
| step, eager transforms | 10000 | 1235 (1227-1247) | 1609 (1598-1617) | 1726 (1724-1730) | 1256 (1255-1263) | 1258 (1255-1266) | 1262 (1258-1266) | **1.02x** | 0.73x |
|
|
64
|
+
| churn, apply after | 1000 | 25 (25-25) | 49 (49-49) | 112 (111-113) | 45 (45-45) | 45 (44-45) | 45 (44-45) | **1.80x** | 0.40x |
|
|
65
|
+
| churn, apply after | 10000 | 821 (819-828) | 687 (685-694) | 1148 (1146-1150) | 416 (415-424) | 415 (415-416) | 415 (415-416) | 0.51x | 0.36x |
|
|
66
|
+
| step, 60 kept | 1000 | - | - | 79 (78-80) | 26 (26-27) | 26 (26-26) | 26 (26-27) | - | 0.33x |
|
|
67
|
+
| step, 60 kept | 10000 | - | - | 2049 (2041-2061) | 1641 (1635-1668) | 1633 (1629-1644) | 1650 (1636-1673) | - | 0.80x |
|
|
68
|
+
| churn, 60 kept | 1000 | - | - | 102 (101-102) | 44 (44-45) | 44 (44-45) | 45 (44-45) | - | 0.43x |
|
|
69
|
+
| churn, 60 kept | 10000 | - | - | 2416 (2407-2418) | 1809 (1795-1835) | 1809 (1794-1816) | 1811 (1802-1819) | - | 0.75x |
|
|
70
|
+
|
|
71
|
+
The N = 100 rows are left out: they're all under 15 ms, at the branch's clock resolution. At N = 100 the branch is 1.8x std/game on step and 2.5x on churn, 0.5x on draw and hit. The mutable trees can't keep snapshots, so they don't run "60 kept".
|
|
72
|
+
|
|
73
|
+
## Games (headless, ported drivers)
|
|
74
|
+
|
|
75
|
+
| game | ticks | master | branch | branch --no-fbip | branch --no-fusion | branch / master | per tick, master / branch |
|
|
76
|
+
|---|---|---|---|---|---|---|---|
|
|
77
|
+
| Orb Run | 13 seeds × 3000 | 424 (422-429) | 603 (599-604) | 600 (599-602) | 600 (599-603) | **1.42x** | 10.9 / 15.5 µs |
|
|
78
|
+
| Balloon Pop | 6 seeds × 20000 | 151 (150-156) | 472 (470-473) | 473 (468-474) | 474 (474-476) | **3.13x** | 1.26 / 3.93 µs |
|
|
79
|
+
|
|
80
|
+
- **Orb Run**: steering keys from a hash of (seed, tick), a pointer move every tick, and Enter every 150 ticks while the game is over. Master's driver starts on the play scene (`OrbitRunner.headless`). The branch's driver presses Enter once on the title screen, before the timed ticks. Both play 5 games to game over with the same scores, and end with 40 mines. The per-tick checksum differs because seed 13 diverges at tick 2695 of 3000: a mine hits the ship on the branch and not on master. It's presumably a near miss that the two compute slightly differently; we didn't trace it. Until then, and in the other 12 seeds, score, lives and game over are the same on every tick (ship positions weren't compared).
|
|
81
|
+
- **Balloon Pop**: a `PointerDown` at ((97t) mod 800, (61t) mod 600) every tick, on an 800 by 600 screen. Both print the same checksum and 3975 pops. The two games are the same rules from the same random numbers.
|
|
82
|
+
|
|
83
|
+
## Compile time and wasm size
|
|
84
|
+
|
|
85
|
+
`plum compile`, median of 5, ms. "branch --no-fbip bytes" was the same as the default except Balloon Pop, at 151,633 bytes (394 fewer).
|
|
86
|
+
|
|
87
|
+
| program | master compile | branch compile | ratio | master wasm bytes | branch wasm bytes | ratio |
|
|
88
|
+
|---|---|---|---|---|---|---|
|
|
89
|
+
| fib | 179 | 195 | 1.09x | 23,047 | 28,083 | 1.22x |
|
|
90
|
+
| loop | 180 | 202 | 1.12x | 23,079 | 28,112 | 1.22x |
|
|
91
|
+
| array | 180 | 206 | 1.15x | 23,526 | 28,371 | 1.21x |
|
|
92
|
+
| map | 182 | 209 | 1.14x | 25,114 | 28,511 | 1.14x |
|
|
93
|
+
| cons | 182 | 217 | 1.19x | 24,162 | 28,879 | 1.20x |
|
|
94
|
+
| cons_rec | 169 | 173 | 1.03x | 23,327 | 23,859 | 1.02x |
|
|
95
|
+
| str | 180 | 203 | 1.12x | 23,103 | 28,147 | 1.22x |
|
|
96
|
+
| particles | 159 | 221 | **1.40x** | 23,161 | 29,901 | 1.29x |
|
|
97
|
+
| trig | 180 | 203 | 1.13x | 23,099 | 28,150 | 1.22x |
|
|
98
|
+
| Orb Run driver | 654 | 3259 | **4.99x** | 87,205 | 178,376 | **2.05x** |
|
|
99
|
+
| Balloon Pop driver | 475 | 2381 | **5.01x** | 73,087 | 152,027 | **2.08x** |
|
|
100
|
+
| scene tree benchmark | 333 / 682 / 671 (game / game_tree / enum tree) | 1409 | 2.1x to 4.2x | 49,066 / 83,463 / 104,094 | 85,255 | 0.8x to 1.7x |
|
|
101
|
+
|
|
102
|
+
`plum build` (compile plus the native executable), median of 5, ms:
|
|
103
|
+
|
|
104
|
+
| program | master | branch | branch --no-fusion | branch --no-fbip |
|
|
105
|
+
|---|---|---|---|---|
|
|
106
|
+
| Orb Run driver | 1372 | 4038 | 3224 | 3794 |
|
|
107
|
+
| Balloon Pop driver | 1221 | 3129 | 2537 | 2971 |
|
|
108
|
+
| fib | 931 | 948 | 911 | 931 |
|
|
109
|
+
|
|
110
|
+
The native step adds about 750 ms to every build on both branches. Fusion accounts for about 800 ms of the branch's Orb Run build and 600 ms of Balloon Pop's. Even without fusion, the branch takes about 3.8 times as long as master to compile a game (about 2.5 s of `plum compile` against 0.65 s).
|
|
111
|
+
|
|
112
|
+
## What stands out
|
|
113
|
+
|
|
114
|
+
1. **Compiling a game is 5 times slower on the branch, and its wasm is 2 times bigger.** This is the biggest difference measured: 3.26 s against 0.65 s for Orb Run, and 178 KB against 87 KB. Fusion is about 0.8 s of the extra. We didn't trace the rest. A likely part of it is that the branch's game std (std/game/scene, Game, Store, ui) is larger than master's and mostly generic, but that wasn't measured. On small programs the gap is 3 to 40%, plus a fixed 5 KB of std.
|
|
115
|
+
2. **The branch's games tick 1.4 to 3.1 times slower.** Balloon Pop has 6 balloons and few actors, and costs 3.9 µs a tick against 1.3 µs. Orb Run has about 60 actors, and costs 15.5 µs against 10.9 µs. The gap per tick is larger in the game with more actors (4.6 µs against 2.7 µs), but the ratio is much larger in the small one. That points to a fixed cost per tick in the branch's `Game.tick` (routing input through the tree, splicing the screen back, the store and the turn fold) on top of a per-actor cost. This is an inference that wasn't profiled. FBIP and fusion make no difference here.
|
|
116
|
+
3. **On scene trees, the branch beats master's persistent tree by 2 to 3 times, and mostly beats the mutable ones.** It's faster than master's `std/game` on draw and hit (0.5x), and on churn at N = 10000 (0.46x). It's slower on plain step (1.17x at N = 10000, 1.29x at 1000) and on churn at N = 1000 (1.6x, 1.8x with the apply walk). It's level with eager transforms (1.02x). Rebuilding every moving body each tick still costs it on step. The earlier finding still holds: none of this comes from FBIP or fusion, since all three branch builds agree within their ranges.
|
|
117
|
+
4. **Master's `LinkedList` std is 27 times slower than the branch's `List` on a map, filter and fold pipeline** (3779 against 137 ms). The language isn't the cause: the same pipeline hand-written as recursion takes 1.85 s on both (`cons_rec`). Master's `map`, `filter` and `fold` walk with `for x := range self`, through the iterator protocol. The branch's std runs that pipeline in 137 ms with fusion, and 997 ms without it. This is the only place where fusion showed up, and it would be worth porting master's `LinkedList` walks to direct recursion.
|
|
118
|
+
5. **Where the branch is slower at small scale:** struct updates through `takeAt`, a spread and `putAt` are 1.24x master's in-place field assignment. `--no-fbip` doesn't change this, so the spread is either already reused or the cost is elsewhere. Naive recursion (`fib`) is 1.12x and float math (`trig`) 1.17x. The branch's std/math is written with recursion where master's uses loops (`sqrt`, for one), which may explain `trig`; we didn't check. Loops, arrays, maps and strings are level within 5%, and the branch is slightly ahead on arrays and maps.
|
|
119
|
+
|
|
120
|
+
## Caveats
|
|
121
|
+
|
|
122
|
+
- Every comparison is between ports. The micro ports are small enough to read side by side. The scene trees and games are different implementations that do the same work, checked by checksums, and by game state for the games.
|
|
123
|
+
- Only update ticks are timed for the games. Drawing goes to the browser host on both branches and wasn't measured.
|
|
124
|
+
- The branch's scene-tree program times itself in whole ms, so its N = 100 cells are coarse.
|
|
125
|
+
- Master's wasm size for the game drivers moves by a few bytes with the driver's file name (87,205 against 87,214 in a check run).
|
|
126
|
+
- All runs are on one machine, in one session, with release compilers. The wasm runs under the wasmtime that `plum build` links in on each branch, and the two branches' runtimes may differ.
|
|
127
|
+
|
|
128
|
+
## How to rerun
|
|
129
|
+
|
|
130
|
+
From a simpler-language checkout, with master's compiler built in a separate checkout:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
cargo build --release -p plum-cli
|
|
134
|
+
(cd <master checkout> && cargo build --release -p plum-cli)
|
|
135
|
+
python3 benchmarks/master_vs_simpler/run.py --master <master checkout> # micro ports and games, 5 rounds
|
|
136
|
+
python3 benchmarks/scene_trees/run.py --master <master checkout> \
|
|
137
|
+
--master-plum <master checkout>/target/release/plum --plum target/release/plum
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The micro ports and games took about 5 minutes here, and the scene trees about 5 minutes.
|