Skip to content

Commit ae5e16e

Browse files
committed
perf: add bench code
1 parent 2b55637 commit ae5e16e

File tree

5 files changed

+228
-3
lines changed

5 files changed

+228
-3
lines changed

Cargo.lock

Lines changed: 202 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ utoipa-redoc = { version = "6.0.0", features = ["actix-web"] }
8989
utoipa-rapidoc = { version = "6.0.0", features = ["actix-web"] }
9090
utoipa-scalar = { version = "0.3.0", features = ["actix-web"] }
9191
uuid = { version = "1.15.1", features = ["v4", "serde", "v7"] }
92-
92+
criterion = "0.5.1"

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
2222
prepare-check \
2323
doc \
2424
fmt \
25+
bench \
2526
clippy \
2627
test \
28+
nextest \
2729
audit \
2830
git.sync \
2931
build \
@@ -79,6 +81,9 @@ fmt :
7981
clippy :
8082
cargo clippy --all-features --all-targets -- -D warnings
8183

84+
bench:
85+
cargo bench --all
86+
8287
# Run Rust tests of project.
8388
#
8489
# Usage :
@@ -87,6 +92,9 @@ clippy :
8792
test :
8893
cargo test --all-features
8994

95+
nextest:
96+
cargo nextest run --all-features --all-targets
97+
9098
# Usage
9199
# make migrate-run new_fancy_table
92100
migrate-create:
@@ -112,4 +120,4 @@ coverage:
112120
cargo llvm-cov clean --workspace --html --output-dir=coverage
113121
cargo llvm-cov --all-features --workspace --no-clean --html --output-dir=coverage --open
114122

115-
precommit : fmt clippy test prepare-check
123+
precommit : fmt clippy test prepare-check bench

cpast/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ ccode_runner = { version = "^0.3.2", path = "../ccode_runner" }
2525
clex_llm = { version = "^0.2.2", path = "../clex_llm" }
2626
thiserror = { workspace = true }
2727

28+
[dev-dependencies]
29+
criterion = { workspace = true }
30+
31+
[[bench]]
32+
name = "generate"
33+
harness = false

cpast/benches/generate.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use criterion::{Criterion, criterion_group, criterion_main};
2+
3+
fn criterion_benchmark(c: &mut Criterion) {
4+
c.bench_function("generate bench", |b| {
5+
b.iter(|| clex_gen::generator("N[1,1000] N{\\1}".to_owned()))
6+
});
7+
}
8+
9+
criterion_group!(benches, criterion_benchmark);
10+
criterion_main!(benches);

0 commit comments

Comments
 (0)