From 91392d0636960fb85386e9db1e168a47cb156e9b Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Thu, 1 Jun 2023 22:20:53 -0700 Subject: [PATCH] Remove criterion benchmarks workspace These benchmarks were useful when this crate was actively developed. Now that the crate is passively maintained, remove this code to reduce maintenance burden, the most recent of which was #221. The removal of the bench CI workflow also makes CI a bit cheaper to run. --- .github/workflows/bench.yaml | 40 ------- benchmarks/.gitignore | 20 ---- benchmarks/Cargo.toml | 21 ---- benchmarks/benches/benchmarks.rs | 179 ------------------------------- benchmarks/src/lib.rs | 7 -- 5 files changed, 267 deletions(-) delete mode 100644 .github/workflows/bench.yaml delete mode 100644 benchmarks/.gitignore delete mode 100644 benchmarks/Cargo.toml delete mode 100644 benchmarks/benches/benchmarks.rs delete mode 100644 benchmarks/src/lib.rs diff --git a/.github/workflows/bench.yaml b/.github/workflows/bench.yaml deleted file mode 100644 index b3c3f793..00000000 --- a/.github/workflows/bench.yaml +++ /dev/null @@ -1,40 +0,0 @@ ---- -name: Bench -"on": - push: - branches: - - trunk - pull_request: - branches: - - trunk - schedule: - - cron: "0 0 * * WED" -jobs: - bench: - name: Bench - runs-on: ubuntu-latest - env: - RUSTFLAGS: -D warnings - RUST_BACKTRACE: 1 - - steps: - - name: Checkout repository - uses: actions/checkout@v3.5.2 - - - name: Install Rust toolchain - uses: artichoke/setup-rust/build-and-test@v1.9.0 - with: - toolchain: stable - - - name: Compile - run: cargo build --verbose - working-directory: benchmarks - - - name: Compile tests - run: cargo bench --no-run - working-directory: benchmarks - - - name: Test - if: github.ref == 'refs/heads/trunk' - run: cargo bench - working-directory: benchmarks diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore deleted file mode 100644 index 389159a3..00000000 --- a/benchmarks/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/rust -# Edit at https://www.toptal.com/developers/gitignore?templates=rust - -### Rust ### -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -# End of https://www.toptal.com/developers/gitignore/api/rust diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml deleted file mode 100644 index 2b0c128c..00000000 --- a/benchmarks/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "benchmarks" -version = "0.1.0" -authors = ["Ryan Lopopolo "] -edition = "2018" -publish = false - -[workspace] -members = ["."] - -[[bench]] -name = "benchmarks" -harness = false - -[dependencies] - -[dev-dependencies] -# Benchmarking support on stable Rust. -criterion = "0.5.1" -# benchmark target -intaglio = { path = ".." } diff --git a/benchmarks/benches/benchmarks.rs b/benchmarks/benches/benchmarks.rs deleted file mode 100644 index 93e1f9a3..00000000 --- a/benchmarks/benches/benchmarks.rs +++ /dev/null @@ -1,179 +0,0 @@ -use criterion::{criterion_group, criterion_main}; - -mod bytestring { - use criterion::{BatchSize, Criterion, Throughput}; - use intaglio::bytes::SymbolTable; - - pub fn bench_allocate(c: &mut Criterion) { - let mut group = c.benchmark_group("bytes::SymbolTable constructors"); - group.bench_function("SymbolTable::new", |b| b.iter(SymbolTable::new)); - group.bench_function("SymbolTable::with_capacity(10)", |b| { - b.iter(|| SymbolTable::with_capacity(10)) - }); - group.bench_function("SymbolTable::with_capacity(0)", |b| { - b.iter(|| SymbolTable::with_capacity(0)) - }); - } - - pub fn bench_repeatedly_intern(c: &mut Criterion) { - let mut group = c.benchmark_group("bytes::SymbolTable::intern single string"); - group.throughput(Throughput::Elements(10_000)); - - let bytestring: &'static [u8] = b"acdefg123456"; - - let strings = vec![bytestring.to_vec(); 10_000]; - group.bench_function("Owned with borrowed first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(bytestring).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - - let strings = vec![bytestring.to_vec(); 10_000]; - group.bench_function("Owned with owned first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(bytestring.to_vec()).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - - let strings = vec![bytestring; 10_000]; - group.bench_function("Static borrowed with borrowed first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(bytestring).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - - let strings = vec![bytestring; 10_000]; - group.bench_function("Static borrowed with owned first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(bytestring.to_vec()).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - } -} - -mod utf8string { - use criterion::{BatchSize, Criterion, Throughput}; - use intaglio::SymbolTable; - - pub fn bench_allocate(c: &mut Criterion) { - let mut group = c.benchmark_group("str::SymbolTable constructors"); - group.bench_function("SymbolTable::new", |b| b.iter(SymbolTable::new)); - group.bench_function("SymbolTable::with_capacity(10)", |b| { - b.iter(|| SymbolTable::with_capacity(10)) - }); - group.bench_function("SymbolTable::with_capacity(0)", |b| { - b.iter(|| SymbolTable::with_capacity(0)) - }); - } - - pub fn bench_repeatedly_intern(c: &mut Criterion) { - let mut group = c.benchmark_group("str::SymbolTable::intern single string"); - group.throughput(Throughput::Elements(10_000)); - - let utf8string: &'static str = "acdefg123456"; - - let strings = vec![utf8string.to_string(); 10_000]; - group.bench_function("Owned with borrowed first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(utf8string).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - - let strings = vec![utf8string.to_string(); 10_000]; - group.bench_function("Owned with owned first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(utf8string.to_string()).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - - let strings = vec![utf8string; 10_000]; - group.bench_function("Static borrowed with borrowed first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(utf8string).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - - let strings = vec![utf8string; 10_000]; - group.bench_function("Static borrowed with owned first", move |b| { - b.iter_batched( - || strings.clone(), - |strings| { - let mut table = SymbolTable::with_capacity(1); - let sym = table.intern(utf8string.to_string()).unwrap(); - for string in strings { - assert_eq!(sym, table.intern(string).unwrap()); - } - }, - BatchSize::SmallInput, - ) - }); - } -} - -criterion_group!( - bytes, - bytestring::bench_allocate, - bytestring::bench_repeatedly_intern, -); -criterion_group!( - utf8, - utf8string::bench_allocate, - utf8string::bench_repeatedly_intern, -); -criterion_main!(bytes, utf8); diff --git a/benchmarks/src/lib.rs b/benchmarks/src/lib.rs deleted file mode 100644 index 31e1bb20..00000000 --- a/benchmarks/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -}