Skip to content

Commit 32aafd0

Browse files
authored
Merge pull request #3 from linksplatform/issue-2-7343f08dd7ad
feat: implement SpacetimeDB 2 vs Doublets Rust benchmark
2 parents bd59e01 + cce83df commit 32aafd0

18 files changed

Lines changed: 2935 additions & 245 deletions
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Rust Benchmark
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
paths: ['rust/**', '.github/workflows/rust-benchmark.yml']
7+
pull_request:
8+
branches: [main, master]
9+
paths: ['rust/**', '.github/workflows/rust-benchmark.yml']
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
RUST_BACKTRACE: 1
14+
15+
defaults:
16+
run:
17+
working-directory: rust
18+
19+
jobs:
20+
test:
21+
name: Test (${{ matrix.os }})
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
os: [ubuntu-latest, macos-latest, windows-latest]
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Setup Rust (nightly-2022-08-22)
31+
uses: dtolnay/rust-toolchain@master
32+
with:
33+
toolchain: nightly-2022-08-22
34+
components: rustfmt, clippy
35+
36+
- name: Cache cargo registry
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.cargo/registry
41+
~/.cargo/git
42+
rust/target
43+
key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-cargo-
46+
47+
- name: Check formatting
48+
run: cargo fmt --all -- --check
49+
50+
- name: Run Clippy
51+
run: cargo clippy --all-targets
52+
53+
- name: Run tests
54+
run: cargo test --release
55+
56+
benchmark:
57+
name: Benchmark
58+
runs-on: ubuntu-latest
59+
needs: [test]
60+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
61+
steps:
62+
- uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
token: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Setup Rust (nightly-2022-08-22)
68+
uses: dtolnay/rust-toolchain@master
69+
with:
70+
toolchain: nightly-2022-08-22
71+
72+
- name: Setup Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: '3.11'
76+
77+
- name: Install Python dependencies
78+
run: pip install matplotlib numpy
79+
80+
- name: Cache cargo registry
81+
uses: actions/cache@v4
82+
with:
83+
path: |
84+
~/.cargo/registry
85+
~/.cargo/git
86+
rust/target
87+
key: ubuntu-cargo-bench-${{ hashFiles('rust/Cargo.lock') }}
88+
restore-keys: |
89+
ubuntu-cargo-bench-
90+
91+
- name: Build benchmark
92+
run: cargo build --release
93+
94+
- name: Run benchmark
95+
env:
96+
BENCHMARK_LINK_COUNT: 1000
97+
BACKGROUND_LINK_COUNT: 3000
98+
run: cargo bench --bench bench -- --output-format bencher | tee out.txt
99+
100+
- name: Generate charts
101+
run: python3 out.py
102+
103+
- name: Configure git
104+
run: |
105+
git config user.name "github-actions[bot]"
106+
git config user.email "github-actions[bot]@users.noreply.github.com"
107+
108+
- name: Commit benchmark results
109+
run: |
110+
git add -f out.txt bench_rust.png bench_rust_log_scale.png 2>/dev/null || true
111+
git diff --staged --quiet || git commit -m "chore: update benchmark results [skip ci]"
112+
git push
113+
114+
- name: Upload benchmark artifacts
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: benchmark-results
118+
path: |
119+
rust/out.txt
120+
rust/bench_rust.png
121+
rust/bench_rust_log_scale.png

0 commit comments

Comments
 (0)