Skip to content

Commit d7dd9b2

Browse files
committed
Added: Benchmarks and plotting for performance analysis
Adds a comprehensive benchmark suite comparing `la-stack` against `nalgebra` for various linear algebra operations across different dimensions. Includes tooling to automatically generate plots and update the README with benchmark results. This facilitates ongoing performance monitoring and optimization.
1 parent 0ad77f6 commit d7dd9b2

21 files changed

+1658
-49
lines changed

.codacy.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# This repository is primarily Rust.
55
# Note: clippy and rustfmt are not supported by Codacy and are handled by GitHub Actions CI.
6+
# cspell:ignore pyproject
67

78
engines:
89
# === DOCUMENTATION / SCRIPTS ===
@@ -22,6 +23,29 @@ engines:
2223
severity: warning
2324
include_code: true
2425

26+
# === PYTHON / SECURITY ===
27+
# Ruff for Python linting and formatting (reads from pyproject.toml)
28+
ruff:
29+
enabled: true
30+
include_paths:
31+
- "scripts/**/*.py"
32+
- "**/*.py"
33+
config:
34+
file: "pyproject.toml"
35+
36+
# Bandit for Python security analysis
37+
bandit:
38+
enabled: true
39+
include_paths:
40+
- "scripts/**/*.py"
41+
- "**/*.py"
42+
config:
43+
severity: high
44+
confidence: high
45+
skips: ["B101", "B102", "B103", "B108", "B110", "B404", "B603", "B607"]
46+
exclude_info: true
47+
exclude_dirs: ["tests"]
48+
2549
# === RUST / SECURITY ===
2650
lizard:
2751
enabled: true
@@ -30,8 +54,9 @@ engines:
3054
- "tests/**/*.rs"
3155
- "examples/**/*.rs"
3256
- "benches/**/*.rs"
57+
- "scripts/**/*.py"
3358
config:
34-
languages: ["rust"]
59+
languages: ["rust", "python"]
3560
threshold:
3661
cyclomatic_complexity: 15
3762
token_count: 300
@@ -46,6 +71,7 @@ engines:
4671
- "tests/**/*.rs"
4772
- "examples/**/*.rs"
4873
- "benches/**/*.rs"
74+
- "scripts/**/*.py"
4975

5076
trivy:
5177
enabled: true
@@ -75,14 +101,26 @@ exclude_paths:
75101
- ".git/**"
76102
- ".cspellcache"
77103
- ".DS_Store"
104+
# Python artifacts
105+
- "__pycache__/**"
106+
- "*.pyc"
107+
- ".pytest_cache/**"
108+
- ".ruff_cache/**"
109+
- ".mypy_cache/**"
110+
- "venv/**"
111+
- ".venv/**"
112+
- "uv.lock"
78113

79114
# Focus analysis on source, docs, and CI configuration
80115
include_paths:
81116
- "src/**"
82117
- "benches/**"
83118
- "examples/**"
84119
- "tests/**"
120+
- "scripts/**"
121+
- "*.py"
85122
- "Cargo.toml"
123+
- "pyproject.toml"
86124
- "rust-toolchain.toml"
87125
- "rustfmt.toml"
88126
- "justfile"
@@ -100,6 +138,9 @@ languages:
100138
rust:
101139
extensions:
102140
- ".rs"
141+
python:
142+
extensions:
143+
- ".py"
103144
markdown:
104145
extensions:
105146
- ".md"

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ jobs:
5555
with:
5656
tool: just
5757

58+
- name: Install uv (for Python scripts and pytest)
59+
if: matrix.os != 'windows-latest'
60+
uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5
61+
with:
62+
version: "latest"
63+
5864
- name: Install Node.js (for markdownlint and cspell)
5965
if: matrix.os != 'windows-latest'
6066
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0

.github/workflows/codacy.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ jobs:
6161
mkdir -p "$CODACY_WORKDIR"
6262
rsync -a --delete --exclude '.git' ./ "$CODACY_WORKDIR/"
6363
64+
- name: Verify Codacy config includes Python security tooling
65+
run: |
66+
set -euo pipefail
67+
config="$CODACY_WORKDIR/.codacy.yml"
68+
if [ ! -f "$config" ]; then
69+
echo "::error::.codacy.yml not found in workspace copy ($config)"
70+
exit 1
71+
fi
72+
if ! grep -qE '^ bandit:' "$config"; then
73+
echo "::error::Bandit engine not configured in .codacy.yml; Python security scanning will be skipped."
74+
exit 1
75+
fi
76+
6477
# Execute Codacy Analysis CLI and generate a SARIF output with
6578
# the security issues identified during the analysis
6679
- name: Run Codacy Analysis CLI

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@
44
/build*
55
/cobertura.xml
66
.DS_Store
7+
8+
# Python / uv
9+
__pycache__/
10+
**/__pycache__/
11+
*.egg-info/
12+
.venv/
13+
.ruff_cache/
14+
.pytest_cache/
15+
.mypy_cache/
16+
uv.lock

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ rust-version = "1.92"
66
license = "BSD-3-Clause"
77
description = "Small, stack-allocated linear algebra for fixed dimensions"
88
readme = "README.md"
9+
documentation = "https://docs.rs/la-stack"
910
repository = "https://github.com/acgetchell/la-stack"
1011
categories = ["mathematics", "science"]
1112
keywords = ["linear-algebra", "geometry", "const-generics"]

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ while keeping the API intentionally small and explicit.
3232
-`unsafe` forbidden
3333
- ✅ No runtime dependencies (dev-dependencies are for contributors only)
3434

35+
## 🚫 Anti-goals
36+
37+
- Comprehensive: use [`nalgebra`](https://crates.io/crates/nalgebra) if you need a full-featured library
38+
- Bare-metal performance: see [`blas-src`](https://crates.io/crates/blas-src), [`lapack-src`](https://crates.io/crates/lapack-src), [`openblas-src`](https://crates.io/crates/openblas-src)
39+
3540
## 🔢 Scalar types
3641

3742
Today, the core types are implemented for `f64`. The intent is to support `f32` and `f64`
@@ -107,6 +112,27 @@ just commit-check # lint + all tests + examples
107112

108113
For the full set of developer commands, see `just --list` and `WARP.md`.
109114

115+
## 📊 Benchmarks (vs nalgebra)
116+
117+
![LU solve (factor + solve): median time vs dimension](docs/assets/bench/vs_nalgebra_lu_solve_median.svg)
118+
119+
Raw data: [docs/assets/bench/vs_nalgebra_lu_solve_median.csv](docs/assets/bench/vs_nalgebra_lu_solve_median.csv)
120+
121+
Summary (median time; lower is better). “la-stack vs nalgebra” is the % time reduction relative to nalgebra (positive = la-stack faster):
122+
123+
<!-- BENCH_TABLE:lu_solve:median:new:BEGIN -->
124+
| D | la-stack median (ns) | nalgebra median (ns) | la-stack vs nalgebra |
125+
|---:|--------------------:|--------------------:|---------------------:|
126+
| 2 | 2.125 | 19.172 | +88.9% |
127+
| 3 | 13.562 | 24.082 | +43.7% |
128+
| 4 | 28.365 | 55.434 | +48.8% |
129+
| 5 | 48.567 | 76.793 | +36.8% |
130+
| 8 | 141.935 | 182.628 | +22.3% |
131+
| 16 | 642.935 | 605.115 | -6.3% |
132+
| 32 | 2,761.816 | 2,505.691 | -10.2% |
133+
| 64 | 17,009.208 | 14,696.410 | -15.7% |
134+
<!-- BENCH_TABLE:lu_solve:median:new:END -->
135+
110136
## 📄 License
111137

112138
BSD 3-Clause License. See [LICENSE](./LICENSE).

0 commit comments

Comments
 (0)