Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General improvements #8

Merged
merged 6 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/results.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Run benchmarks
on:
pull_request:
workflow_dispatch:
push:
paths-ignore:
Expand All @@ -17,20 +18,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install LuaJIT
run: sudo apt-get install -y luajit

- name: Setup PyPy
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: pypy2
python-version: pypy3.10

- name: Run benchmarks
run: node bench.js

- name: Commit new results
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch'
uses: EndBug/add-and-commit@v7
with:
add: README.md
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ perfcsharpsrc/obj
# Rust build files
perfrustsrc/Cargo.lock
perfrustsrc/target
perfrs
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ Benchmark results of GitHub Actions runner. Smaller is better.
## Dependencies

- [Java JDK](https://adoptopenjdk.net/)
- [Rust/Cargo](https://www.rust-lang.org/tools/install)
- [Rust](https://www.rust-lang.org/tools/install)
- [Go](https://golang.org/doc/install)
- [PyPy](https://www.pypy.org/download.html)
- [PyPy3](https://www.pypy.org/download.html)
- [LuaJIT](https://luajit.org/download.html)
- GCC ([MinGW](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download) on Windows\*)
- [Node.js](https://nodejs.org/en/download/)
- [.NET 5.0 SDK](https://dotnet.microsoft.com/download/dotnet/5.0)
- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)

Each program needs to be added to PATH if the associated installer or package doesn't do so automatically.

Expand Down
29 changes: 14 additions & 15 deletions bench
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
#!/bin/sh
#!/bin/sh -e
echo "Very cool language benchmark script"
echo "---"
echo "Node.js"
echo "Node.js $(node -v)"
node perf.js
echo "---"
echo "Lua (LuaJIT)"
echo "Lua (LuaJIT) $(luajit -v | awk '{print $1, $2}')"
luajit perf.lua
echo "---"
echo "Rust"
cd perfrustsrc
cargo run -q --release
cd ..
echo "Rust $(rustc --version)"
rustc perf.rs -C opt-level=3 -C codegen-units=1 -C lto=true -C target-cpu=native -o perfrs
./perfrs
echo "---"
echo "Go"
echo "Go $(go version | awk '{print $3, $4}')"
go run perf.go
echo "---"
echo "Python (PyPy)"
pypy perf.py
echo "Python (PyPy3) $(pypy3 --version)"
pypy3 perf.py
echo "---"
echo "C (GCC)"
echo "C (GCC) $(gcc --version | head -n 1)"
gcc perf.c -Ofast -march=native -mtune=native -o perfc
./perfc
echo "---"
echo "C++ (G++)"
g++ perf.cpp -march=native -mtune=native -Ofast -o perfcpp
echo "C++ (G++) $(g++ --version | head -n 1)"
g++ perf.cpp -std=c++11 -march=native -mtune=native -Ofast -o perfcpp
./perfcpp
echo "---"
echo "C#"
echo "C# $(dotnet --version)"
cd perfcsharpsrc
dotnet run --configuration Release --verbosity quiet
cd ..
echo "---"
echo "Java"
echo "Java $(java -version 2>&1 | head -n 1)"
javac perf.java
java perf
echo "---"
9 changes: 4 additions & 5 deletions bench.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@ echo Lua (LuaJIT)
luajit perf.lua
echo ---
echo Rust
cd perfrustsrc
cargo run -q --release
cd ..
rustc perf.rs -C opt-level=3 -C codegen-units=1 -C lto=true -C target-cpu=native -o perfrs.exe
perfrs.exe
echo ---
echo Go
go run perf.go
echo ---
echo Python (PyPy)
echo Python (PyPy3)
pypy3 perf.py
echo ---
echo C (GCC)
gcc perf.c -march=native -mtune=native -Ofast -o perfc.exe
perfc.exe
echo ---
echo C++ (G++)
g++ perf.cpp -march=native -mtune=native -Ofast -o perfcpp.exe
g++ perf.cpp -std=c++11 -march=native -mtune=native -Ofast -o perfcpp.exe
perfcpp.exe
echo ---
echo C#
Expand Down
10 changes: 5 additions & 5 deletions bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const benchmarks = [
perf: "node perf.js"
},
{
name: "Python (PyPy)",
perf: "pypy perf.py"
name: "Python (PyPy3)",
perf: "pypy3 perf.py"
},
{
name: "Lua (LuaJIT)",
perf: "luajit perf.lua"
},
{
name: "Rust",
perf: "cargo run -q --release",
cwd: "./perfrustsrc/"
build: "rustc perf.rs -C opt-level=3 -C codegen-units=1 -C lto=true -C target-cpu=native -o perfrs",
perf: "./perfrs",
},
{
name: "Go",
Expand All @@ -35,7 +35,7 @@ const benchmarks = [
},
{
name: "C++ (G++)",
build: "g++ perf.cpp -march=native -mtune=native -Ofast -o perfcpp",
build: "g++ perf.cpp -std=c++11 -march=native -mtune=native -Ofast -o perfcpp",
perf: "./perfcpp"
},
{
Expand Down
8 changes: 6 additions & 2 deletions perfrustsrc/src/main.rs → perf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use time::Instant;
use std::time::Instant;
fn main() {
let start = Instant::now();
let mut n = 0_u32;
Expand All @@ -10,5 +10,9 @@ fn main() {
}
}
println!("{}", n);
println!("{}.{}s", start.elapsed().whole_seconds(), start.elapsed().subsec_milliseconds());
println!(
"{}.{}s",
start.elapsed().as_secs(),
start.elapsed().subsec_millis()
);
}
2 changes: 1 addition & 1 deletion perfcsharpsrc/perf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

</Project>
14 changes: 0 additions & 14 deletions perfrustsrc/Cargo.toml

This file was deleted.