Skip to content

Commit 9a3ddd7

Browse files
committed
add macos bench
1 parent dfcd4a9 commit 9a3ddd7

3 files changed

Lines changed: 102 additions & 29 deletions

File tree

README.md

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -127,41 +127,18 @@ The project is continuously validated against the official Lua 5.5 test suite. T
127127
./run_benchmarks.sh
128128
```
129129

130-
The benchmark scripts cover arithmetic, control flow, coroutines, functions, iterators, metatables, strings, tables, and more. The README snapshot below comes from `run_benchmarks.ps1` on Windows with a Ryzen 7 5800X, comparing luars against native Lua 5.5 on the same machine.
130+
The benchmark scripts cover arithmetic, control flow, coroutines, functions, iterators, metatables, strings, tables, and more. The Windows snapshot linked below comes from `run_benchmarks.ps1` on Windows with a Ryzen 7 5800X, comparing luars against native Lua 5.5 on the same machine.
131131

132-
On this project, Linux results are typically about 10% lower than the Windows snapshot below, while macOS tends to perform better on most workloads.
132+
On this project, Linux results are typically about 10% lower than the Windows snapshot, while macOS tends to perform better on most workloads.
133133

134134
### Benchmark Snapshot
135135

136-
The chart below is a script-level summary from the current Windows run of `run_benchmarks.ps1`. Values are shown as `luars / native Lua * 100`, so `100` means parity with native Lua, `120` means luars is about 20% faster, and `80` means it is about 20% slower.
136+
The platform snapshots now live in dedicated documents:
137137

138-
```mermaid
139-
xychart-beta
140-
title "luars vs native Lua 5.5 on Windows (Ryzen 7 5800X)"
141-
x-axis [arith, control, locals, funcs, closures, multiret, tables, tablelib, iters, math, meta, oop, coroutines, errors]
142-
y-axis "Relative throughput (%)" 0 --> 160
143-
bar [111, 87, 132, 92, 80, 78, 92, 118, 93, 98, 78, 92, 152, 103]
144-
line [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
145-
```
138+
- [windows.md](docs/benchmarks/windows.md): the Windows snapshot with Ryzen 7 5800X
139+
- [macos.md](docs/benchmarks/macos.md): the macOS snapshot with an Apple M4 by @Bruce
146140

147-
| Script | Relative throughput |
148-
|--------|---------------------|
149-
| `bench_arithmetic.lua` | 111% |
150-
| `bench_control_flow.lua` | 87% |
151-
| `bench_locals.lua` | 132% |
152-
| `bench_functions.lua` | 92% |
153-
| `bench_closures.lua` | 80% |
154-
| `bench_multiret.lua` | 78% |
155-
| `bench_tables.lua` | 92% |
156-
| `bench_table_lib.lua` | 118% |
157-
| `bench_iterators.lua` | 93% |
158-
| `bench_math.lua` | 98% |
159-
| `bench_metatables.lua` | 78% |
160-
| `bench_oop.lua` | 92% |
161-
| `bench_coroutines.lua` | 152% |
162-
| `bench_errors.lua` | 103% |
163-
164-
String-heavy microbenchmarks are intentionally left out of the chart because several subtests complete too quickly on Windows timer resolution, which can produce distorted summary ratios. For full raw output, run `run_benchmarks.ps1` directly and inspect the per-subtest numbers.
141+
If you want the raw terminal output instead of the summarized charts, run `run_benchmarks.ps1` on Windows or `./run_benchmarks.sh` on macOS/Linux and inspect the per-subtest numbers directly.
165142

166143
## Cargo Features
167144

docs/benchmarks/macos.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# macOS Benchmark Snapshot
2+
3+
This page summarizes the current macOS benchmark
4+
5+
Environment:
6+
- Script runner: `run_benchmarks.sh`
7+
- Platform: macOS
8+
- Baseline: native Lua 5.5 on the same machine
9+
10+
Method:
11+
- Values are shown as `luars / native Lua * 100`
12+
- Each script summary is computed as the geometric mean of the per-subtest throughput ratios parsed from [2.txt](2.txt)
13+
- `100` means parity with native Lua
14+
- `120` means luars is about 20% faster
15+
- `80` means luars is about 20% slower
16+
17+
```mermaid
18+
xychart-beta
19+
title "luars vs native Lua 5.5 on macOS"
20+
x-axis [arith, control, locals, funcs, closures, multiret, tables, tablelib, iters, math, meta, oop, coroutines, errors]
21+
y-axis "Relative throughput (%)" 0 --> 320
22+
bar [136, 143, 143, 119, 99, 105, 141, 301, 123, 140, 121, 109, 113, 120]
23+
line [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
24+
```
25+
26+
| Script | Relative throughput |
27+
|--------|---------------------|
28+
| `bench_arithmetic.lua` | 136% |
29+
| `bench_control_flow.lua` | 143% |
30+
| `bench_locals.lua` | 143% |
31+
| `bench_functions.lua` | 119% |
32+
| `bench_closures.lua` | 99% |
33+
| `bench_multiret.lua` | 105% |
34+
| `bench_tables.lua` | 141% |
35+
| `bench_table_lib.lua` | 301% |
36+
| `bench_iterators.lua` | 123% |
37+
| `bench_math.lua` | 140% |
38+
| `bench_metatables.lua` | 121% |
39+
| `bench_oop.lua` | 109% |
40+
| `bench_coroutines.lua` | 113% |
41+
| `bench_errors.lua` | 120% |
42+
43+
Highlights:
44+
- The strongest macOS win in this run is `bench_table_lib.lua`, mainly because `table.insert`, `table.remove`, `table.sort`, and `table.move` all outperform native Lua by a large margin in the raw run.
45+
- `bench_control_flow.lua`, `bench_locals.lua`, `bench_tables.lua`, and `bench_math.lua` also show broad wins across most subtests.
46+
- `bench_closures.lua` is effectively at parity in this run.
47+
48+
String microbenchmarks from the same raw capture:
49+
- `bench_strings.lua`: about 99%
50+
- `bench_string_lib.lua`: about 120%

docs/benchmarks/windows.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Windows Benchmark Snapshot
2+
3+
This page contains the current Windows benchmark snapshot that used to live in the main README.
4+
5+
Environment:
6+
- Script runner: `run_benchmarks.ps1`
7+
- Platform: Windows
8+
- CPU: Ryzen 7 5800X
9+
- Baseline: native Lua 5.5 on the same machine
10+
11+
Method:
12+
- Values are shown as `luars / native Lua * 100`
13+
- `100` means parity with native Lua
14+
- `120` means luars is about 20% faster
15+
- `80` means luars is about 20% slower
16+
17+
```mermaid
18+
xychart-beta
19+
title "luars vs native Lua 5.5 on Windows (Ryzen 7 5800X)"
20+
x-axis [arith, control, locals, funcs, closures, multiret, tables, tablelib, iters, math, meta, oop, coroutines, errors]
21+
y-axis "Relative throughput (%)" 0 --> 160
22+
bar [111, 87, 132, 92, 80, 78, 92, 118, 93, 98, 78, 92, 152, 103]
23+
line [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
24+
```
25+
26+
| Script | Relative throughput |
27+
|--------|---------------------|
28+
| `bench_arithmetic.lua` | 111% |
29+
| `bench_control_flow.lua` | 87% |
30+
| `bench_locals.lua` | 132% |
31+
| `bench_functions.lua` | 92% |
32+
| `bench_closures.lua` | 80% |
33+
| `bench_multiret.lua` | 78% |
34+
| `bench_tables.lua` | 92% |
35+
| `bench_table_lib.lua` | 118% |
36+
| `bench_iterators.lua` | 93% |
37+
| `bench_math.lua` | 98% |
38+
| `bench_metatables.lua` | 78% |
39+
| `bench_oop.lua` | 92% |
40+
| `bench_coroutines.lua` | 152% |
41+
| `bench_errors.lua` | 103% |
42+
43+
Notes:
44+
- This is a script-level summary from the current Windows run of `run_benchmarks.ps1`.
45+
- String-heavy microbenchmarks are intentionally left out of the chart because several subtests complete too quickly on Windows timer resolution, which can distort summary ratios.
46+
- For full raw output, run `run_benchmarks.ps1` directly and inspect the per-subtest numbers.

0 commit comments

Comments
 (0)