Skip to content

Commit b9f3884

Browse files
authored
Merge pull request #5 from CppCXY/refactor
Refactor
2 parents d3973e1 + 5f2c6d9 commit b9f3884

30 files changed

+6756
-3110
lines changed

.github/workflows/benchmarks.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Benchmarks
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch: # Allow manual trigger
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
benchmark-linux:
15+
name: Benchmark (Linux)
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install Rust
21+
uses: dtolnay/rust-toolchain@stable
22+
23+
- name: Install build dependencies
24+
run: sudo apt-get update && sudo apt-get install -y build-essential libreadline-dev unzip
25+
26+
- name: Extract Lua source
27+
run: |
28+
cd lua_src
29+
unzip -o lua-5.4.6.zip
30+
31+
- name: Build and Install Native Lua from source
32+
run: |
33+
cd lua_src/lua-5.4.6
34+
make linux
35+
sudo make install INSTALL_TOP=/usr/local
36+
echo "/usr/local/bin" >> $GITHUB_PATH
37+
38+
- name: Verify Lua installation
39+
run: |
40+
which lua
41+
lua -v
42+
43+
- name: Build Release
44+
run: cargo build --release
45+
46+
- name: Run Benchmarks
47+
run: |
48+
echo "## Benchmark Results - Linux (ubuntu-latest)" >> $GITHUB_STEP_SUMMARY
49+
echo "" >> $GITHUB_STEP_SUMMARY
50+
echo '```' >> $GITHUB_STEP_SUMMARY
51+
chmod +x run_benchmarks.sh
52+
./run_benchmarks.sh --nocolor 2>&1 | tee -a $GITHUB_STEP_SUMMARY
53+
echo '```' >> $GITHUB_STEP_SUMMARY
54+
55+
benchmark-windows:
56+
name: Benchmark (Windows)
57+
runs-on: windows-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Install Rust
62+
uses: dtolnay/rust-toolchain@stable
63+
64+
- name: Extract Lua source
65+
shell: pwsh
66+
run: |
67+
cd lua_src
68+
Expand-Archive -Path lua-5.4.6.zip -DestinationPath . -Force
69+
70+
- name: Build Native Lua with CMake
71+
shell: pwsh
72+
run: |
73+
cd lua_src/lua-5.4.6
74+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DLUA_BUILD_INTERPRETER=ON
75+
cmake --build build --config Release
76+
# Add to PATH for this job
77+
$luaPath = "$PWD\build\Release"
78+
echo "$luaPath" >> $env:GITHUB_PATH
79+
# Also copy to a known location
80+
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\lua_bin"
81+
Copy-Item "build\Release\lua.exe" "$env:GITHUB_WORKSPACE\lua_bin\"
82+
83+
- name: Verify Lua installation
84+
shell: pwsh
85+
run: |
86+
$env:PATH = "$env:GITHUB_WORKSPACE\lua_bin;$env:PATH"
87+
& "$env:GITHUB_WORKSPACE\lua_bin\lua.exe" -v
88+
89+
- name: Build Release
90+
run: cargo build --release
91+
92+
- name: Run Benchmarks
93+
shell: pwsh
94+
run: |
95+
$env:PATH = "$env:GITHUB_WORKSPACE\lua_bin;$env:PATH"
96+
echo "## Benchmark Results - Windows (windows-latest)" >> $env:GITHUB_STEP_SUMMARY
97+
echo "" >> $env:GITHUB_STEP_SUMMARY
98+
echo '```' >> $env:GITHUB_STEP_SUMMARY
99+
# Use the lua we built
100+
$env:NATIVE_LUA = "$env:GITHUB_WORKSPACE\lua_bin\lua.exe"
101+
.\run_benchmarks.ps1 -NoColor 2>&1 | Tee-Object -Append -FilePath $env:GITHUB_STEP_SUMMARY
102+
echo '```' >> $env:GITHUB_STEP_SUMMARY
103+
104+
benchmark-macos:
105+
name: Benchmark (macOS)
106+
runs-on: macos-latest
107+
steps:
108+
- uses: actions/checkout@v4
109+
110+
- name: Install Rust
111+
uses: dtolnay/rust-toolchain@stable
112+
113+
- name: Install build dependencies
114+
run: brew install readline
115+
116+
- name: Extract Lua source
117+
run: |
118+
cd lua_src
119+
unzip -o lua-5.4.6.zip
120+
121+
- name: Build and Install Native Lua from source
122+
run: |
123+
cd lua_src/lua-5.4.6
124+
make macosx
125+
sudo make install INSTALL_TOP=/usr/local
126+
echo "/usr/local/bin" >> $GITHUB_PATH
127+
128+
- name: Verify Lua installation
129+
run: |
130+
which lua
131+
lua -v
132+
133+
- name: Build Release
134+
run: cargo build --release
135+
136+
- name: Run Benchmarks
137+
run: |
138+
echo "## Benchmark Results - macOS (macos-latest)" >> $GITHUB_STEP_SUMMARY
139+
echo "" >> $GITHUB_STEP_SUMMARY
140+
echo '```' >> $GITHUB_STEP_SUMMARY
141+
chmod +x run_benchmarks.sh
142+
./run_benchmarks.sh --nocolor 2>&1 | tee -a $GITHUB_STEP_SUMMARY
143+
echo '```' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)