From 430f0e551ec7b3003dbff3587e097162c4648175 Mon Sep 17 00:00:00 2001 From: Tpt Date: Mon, 1 Jan 2024 13:40:53 +0100 Subject: [PATCH] Setup codspeed --- .github/workflows/build.yml | 29 ++++++++++++++++++++++++++--- Cargo.toml | 6 +++--- benches/lib.rs | 15 +++++---------- src/lib.rs | 4 ---- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3894efc..8a2022f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,14 @@ name: build -on: [ push, pull_request ] +on: + pull_request: + branches: + - main + push: + branches: + - main + schedule: + - cron: "12 3 * * *" jobs: fmt: @@ -23,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: rustup update && rustup override set 1.58.0 && rustup component add clippy + - run: rustup update && rustup override set 1.70.0 && rustup component add clippy - uses: Swatinem/rust-cache@v2 - run: cargo clippy --all-targets -- -D warnings -D clippy::all - run: cargo clippy --all-targets --all-features -- -D warnings -D clippy::all @@ -52,7 +60,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: rustup update && rustup override set 1.58.0 + - run: rustup update && rustup override set 1.70.0 - uses: Swatinem/rust-cache@v2 - run: cargo doc --all-features --no-deps env: @@ -85,3 +93,18 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: cargo install typos-cli || true - run: typos + + codspeed: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - run: rustup update + - uses: Swatinem/rust-cache@v2 + - run: cargo install cargo-codspeed || true + - run: cargo codspeed build + - uses: CodSpeedHQ/action@v2 + with: + run: cargo codspeed run + token: ${{ secrets.CODSPEED_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 7330de8..df3e447 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,14 +10,14 @@ repository = "https://github.com/oxigraph/oxiri" description = """ Simple and fast implementation of IRI validation and relative IRI resolution """ -edition = "2018" -rust-version = "1.58" +edition = "2021" +rust-version = "1.60" [dependencies] serde = { version = "1", optional = true } [dev-dependencies] -criterion = "0.4" +codspeed-criterion-compat = "2.3.3" serde_test = "1" [[bench]] diff --git a/benches/lib.rs b/benches/lib.rs index 47bd777..fba308d 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -1,4 +1,4 @@ -use criterion::{criterion_group, criterion_main, Criterion}; +use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion}; use oxiri::{Iri, IriRef}; fn abs_examples() -> &'static [&'static str] { @@ -30,7 +30,7 @@ fn abs_examples() -> &'static [&'static str] { ] } -fn bench_iri_parse(c: &mut Criterion) { +fn iri_parse(c: &mut Criterion) { c.bench_function("Iri::parse", |b| { b.iter(|| { for iri in abs_examples().iter() { @@ -40,7 +40,7 @@ fn bench_iri_parse(c: &mut Criterion) { }); } -fn bench_iri_parse_relative(c: &mut Criterion) { +fn iri_parse_relative(c: &mut Criterion) { c.bench_function("IriRef::parse", |b| { b.iter(|| { for iri in abs_examples().iter() { @@ -50,7 +50,7 @@ fn bench_iri_parse_relative(c: &mut Criterion) { }); } -fn bench_iri_resolve(c: &mut Criterion) { +fn iri_resolve(c: &mut Criterion) { let examples = [ "g:h", "g", @@ -110,11 +110,6 @@ fn bench_iri_resolve(c: &mut Criterion) { }); } -criterion_group!( - iri, - bench_iri_parse, - bench_iri_parse_relative, - bench_iri_resolve -); +criterion_group!(iri, iri_parse, iri_parse_relative, iri_resolve); criterion_main!(iri); diff --git a/src/lib.rs b/src/lib.rs index d24bc0b..6e51966 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1407,7 +1407,6 @@ impl<'a, O: OutputBuffer> IriParser<'a, O> { .truncate(last_slash_position + self.output_positions.authority_end) } - #[inline] fn read_url_codepoint_or_echar(&mut self, c: char) -> Result<(), IriParseError> { if c == '%' { self.read_echar() @@ -1419,7 +1418,6 @@ impl<'a, O: OutputBuffer> IriParser<'a, O> { } } - #[inline] fn read_url_query_codepoint_or_echar(&mut self, c: char) -> Result<(), IriParseError> { if c == '%' { self.read_echar() @@ -1431,7 +1429,6 @@ impl<'a, O: OutputBuffer> IriParser<'a, O> { } } - #[inline] fn read_echar(&mut self) -> Result<(), IriParseError> { let c1 = self.input.next(); let c2 = self.input.next(); @@ -1451,7 +1448,6 @@ impl<'a, O: OutputBuffer> IriParser<'a, O> { } } - #[inline] fn parse_error(&self, kind: IriParseErrorKind) -> Result { Err(IriParseError { kind }) }