diff --git a/.github/workflows/results.yml b/.github/workflows/results.yml index 8e65077..5a1582d 100644 --- a/.github/workflows/results.yml +++ b/.github/workflows/results.yml @@ -1,5 +1,6 @@ name: Run benchmarks on: + pull_request: workflow_dispatch: push: paths-ignore: @@ -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 diff --git a/.gitignore b/.gitignore index 1fb5591..353007c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ perfcsharpsrc/obj # Rust build files perfrustsrc/Cargo.lock perfrustsrc/target +perfrs \ No newline at end of file diff --git a/README.md b/README.md index 9c33fd7..c1219d3 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/bench b/bench index f908db1..0e5a946 100755 --- a/bench +++ b/bench @@ -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 "---" diff --git a/bench.bat b/bench.bat index 2b974ff..3b6f0e5 100644 --- a/bench.bat +++ b/bench.bat @@ -8,14 +8,13 @@ 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) @@ -23,7 +22,7 @@ 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# diff --git a/bench.js b/bench.js index fd54c9f..d88bc37 100644 --- a/bench.js +++ b/bench.js @@ -12,8 +12,8 @@ const benchmarks = [ perf: "node perf.js" }, { - name: "Python (PyPy)", - perf: "pypy perf.py" + name: "Python (PyPy3)", + perf: "pypy3 perf.py" }, { name: "Lua (LuaJIT)", @@ -21,8 +21,8 @@ const benchmarks = [ }, { 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", @@ -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" }, { diff --git a/perfrustsrc/src/main.rs b/perf.rs similarity index 62% rename from perfrustsrc/src/main.rs rename to perf.rs index 32808f9..87b48ac 100644 --- a/perfrustsrc/src/main.rs +++ b/perf.rs @@ -1,4 +1,4 @@ -use time::Instant; +use std::time::Instant; fn main() { let start = Instant::now(); let mut n = 0_u32; @@ -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() + ); } diff --git a/perfcsharpsrc/perf.csproj b/perfcsharpsrc/perf.csproj index 2082704..a269962 100644 --- a/perfcsharpsrc/perf.csproj +++ b/perfcsharpsrc/perf.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net8.0 diff --git a/perfrustsrc/Cargo.toml b/perfrustsrc/Cargo.toml deleted file mode 100644 index fe0e4d9..0000000 --- a/perfrustsrc/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "perfrust" -version = "0.1.0" -authors = ["DrVilepis"] -edition = "2018" - -[dependencies] -time = "*" - -[profile.release] -opt-level = 3 - -[profile.dev] -opt-level = 3