Skip to content

Commit

Permalink
perf: add bench code
Browse files Browse the repository at this point in the history
  • Loading branch information
rootCircle committed Mar 4, 2025
1 parent 2b55637 commit ae5e16e
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 3 deletions.
203 changes: 202 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ utoipa-redoc = { version = "6.0.0", features = ["actix-web"] }
utoipa-rapidoc = { version = "6.0.0", features = ["actix-web"] }
utoipa-scalar = { version = "0.3.0", features = ["actix-web"] }
uuid = { version = "1.15.1", features = ["v4", "serde", "v7"] }

criterion = "0.5.1"
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
prepare-check \
doc \
fmt \
bench \
clippy \
test \
nextest \
audit \
git.sync \
build \
Expand Down Expand Up @@ -79,6 +81,9 @@ fmt :
clippy :
cargo clippy --all-features --all-targets -- -D warnings

bench:
cargo bench --all

# Run Rust tests of project.
#
# Usage :
Expand All @@ -87,6 +92,9 @@ clippy :
test :
cargo test --all-features

nextest:
cargo nextest run --all-features --all-targets

# Usage
# make migrate-run new_fancy_table
migrate-create:
Expand All @@ -112,4 +120,4 @@ coverage:
cargo llvm-cov clean --workspace --html --output-dir=coverage
cargo llvm-cov --all-features --workspace --no-clean --html --output-dir=coverage --open

precommit : fmt clippy test prepare-check
precommit : fmt clippy test prepare-check bench
6 changes: 6 additions & 0 deletions cpast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ ccode_runner = { version = "^0.3.2", path = "../ccode_runner" }
clex_llm = { version = "^0.2.2", path = "../clex_llm" }
thiserror = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }

[[bench]]
name = "generate"
harness = false
10 changes: 10 additions & 0 deletions cpast/benches/generate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use criterion::{Criterion, criterion_group, criterion_main};

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("generate bench", |b| {
b.iter(|| clex_gen::generator("N[1,1000] N{\\1}".to_owned()))
});
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);

0 comments on commit ae5e16e

Please sign in to comment.