Skip to content

Commit 243491c

Browse files
author
szy
committed
feat: add benches and MAX_ZONES=32
1 parent 409fff0 commit 243491c

20 files changed

+1741
-54
lines changed

.github/workflows/check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: Swatinem/rust-cache@v2
3838

3939
- name: Run clippy
40-
run: cargo clippy --all-features -- -D warnings
40+
run: cargo clippy --features log,tracking -- -D warnings
4141

4242
build:
4343
name: Build
@@ -55,7 +55,7 @@ jobs:
5555
uses: Swatinem/rust-cache@v2
5656

5757
- name: Build library
58-
run: cargo build --all-features
58+
run: cargo build --features log,tracking
5959

6060
doc:
6161
name: Documentation
@@ -73,4 +73,4 @@ jobs:
7373
uses: Swatinem/rust-cache@v2
7474

7575
- name: Build documentation
76-
run: cargo doc --no-deps --all-features
76+
run: cargo doc --no-deps --features log,tracking

.github/workflows/deploy.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ jobs:
2626
uses: ./.github/workflows/test.yml
2727
needs: check
2828

29+
benchmark:
30+
name: Benchmark check
31+
runs-on: ubuntu-latest
32+
needs: check
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Install Rust 1.93.0
38+
uses: dtolnay/rust-toolchain@master
39+
with:
40+
toolchain: "1.93.0"
41+
42+
- name: Rust Cache
43+
uses: Swatinem/rust-cache@v2
44+
45+
- name: Build benchmarks
46+
run: cargo +1.93.0 bench --features bench --no-run
47+
2948
build-doc:
3049
name: Build documentation
3150
runs-on: ubuntu-latest
@@ -43,7 +62,7 @@ jobs:
4362
uses: Swatinem/rust-cache@v2
4463

4564
- name: Build docs
46-
run: cargo doc --no-deps --all-features
65+
run: cargo doc --no-deps --features log,tracking
4766

4867
- name: Create index redirect
4968
run: |

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
uses: Swatinem/rust-cache@v2
2121

2222
- name: Run all tests
23-
run: cargo test --all-features
23+
run: cargo test --features log,tracking

Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,34 @@ categories = ["memory-management", "no-std", "embedded"]
1515
default = []
1616
log = ["dep:log"]
1717
tracking = []
18+
# Enable benchmarking (requires criterion and rand as regular dependencies)
19+
bench = ["dep:criterion", "dep:rand"]
1820

1921
[dependencies]
2022
log = { version = "0.4", optional = true }
2123
cfg-if = "1.0"
24+
criterion = { version = "0.4", features = ["html_reports"], optional = true }
25+
rand = { version = "0.8", features = ["small_rng"], optional = true }
26+
27+
[[bench]]
28+
name = "global_allocator"
29+
harness = false
30+
required-features = ["bench"]
31+
32+
[[bench]]
33+
name = "buddy_allocator"
34+
harness = false
35+
required-features = ["bench"]
36+
37+
[[bench]]
38+
name = "slab_allocator"
39+
harness = false
40+
required-features = ["bench"]
41+
42+
[[bench]]
43+
name = "stability"
44+
harness = false
45+
required-features = ["bench"]
46+
2247

2348

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ cargo test --package buddy-slab-allocator --features log
151151
cargo test --package buddy-slab-allocator --features tracking
152152
```
153153

154+
## Benchmarking
155+
156+
This project includes comprehensive benchmarks to evaluate performance and stability under various conditions. For detailed instructions, see `benches/README.md`.
157+
158+
```bash
159+
# Run all benchmarks
160+
cargo bench --features bench
161+
```
162+
163+
For detailed usage instructions, refer to `benches/README.md`.
164+
154165
## Documentation
155166

156167
API documentation is available on [docs.rs](https://docs.rs/buddy-slab-allocator).

README_CN.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ cargo test --package buddy-slab-allocator --features log
151151
cargo test --package buddy-slab-allocator --features tracking
152152
```
153153

154+
## 性能测试
155+
156+
此项目包含全面的性能测试,用于在各种条件下评估分配器的性能和稳定性。详细的中文说明请查看 `benches/README_CN.md`
157+
158+
```bash
159+
# 运行所有 benchmark
160+
cargo bench --features bench
161+
```
162+
163+
详细使用方法请参考 `benches/README_CN.md`
164+
154165
## 文档
155166

156167
API 文档可在 [docs.rs](https://docs.rs/buddy-slab-allocator) 上查看。

0 commit comments

Comments
 (0)