Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bench via criterion and codspeed #35

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,24 @@ jobs:
version: latest
args: --all-targets --all-features

benchmarks:
name: Test performance on benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup rust toolchain, cache and cargo-codspeed binary
uses: moonrepo/setup-rust@v0
with:
channel: stable
cache-target: release
bins: cargo-codspeed

- name: Build the benchmark target(s)
run: cargo codspeed build

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ nom-span = "0.1.1"
thiserror = "1.0.50"

[dev-dependencies]
codspeed-criterion-compat = "2.3.3"
criterion = "0.3"
pretty_assertions_sorted = "1.2.3"

[[bench]]
name = "simple_parse"
harness = false

[package.metadata.cargo-udeps.ignore]
development = ["criterion"]
13 changes: 13 additions & 0 deletions benches/simple_parse.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use asciidoc_parser::Document;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

const TWO_BLOCKS_AND_TITLE: &str = "= Example Title\n\nabc\n\ndef";

pub fn two_blocks_and_title(c: &mut Criterion) {
c.bench_function("2 blocks + title", |b| {
b.iter(|| Document::parse(black_box(TWO_BLOCKS_AND_TITLE)))
});
}

criterion_group!(benches, two_blocks_and_title);
criterion_main!(benches);
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ targets = [
{ triple = "x86_64-pc-windows-msvc" },
{ triple = "aarch64-apple-darwin" },
]
exclude-dev = true

# Deny all advisories unless explicitly ignored.
[advisories]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
pub mod blocks;

pub mod document;
pub use document::Document;

mod error;
pub use error::{Error, ParseResult};
Expand Down
Loading