criterion-polyglot

Crates.iocriterion-polyglot
lib.rscriterion-polyglot
version0.1.0
sourcesrc
created_at2022-12-07 19:55:00.698336
updated_at2022-12-07 19:55:00.698336
descriptionAn extension trait for criterion providing benchmark methods for various non-Rust programming languages
homepagehttps://codeberg.org/overhacked/criterion-polyglot/
repositoryhttps://codeberg.org/overhacked/criterion-polyglot/
max_upload_size
id732105
size83,004
Ross Williams (overhacked)

documentation

README

crates.io docs.rs Maintenance

criterion-polyglot

An extension for Criterion.rs that provides benchmark methods for various non-Rust programming languages.

Currently Supported Languages

  • Python 3
  • Ruby
  • Go
  • Zig
  • C

Synopsis

In your crate's benches/benchmark.rs:

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion_polyglot::{BenchSpec, CriterionPolyglotExt};

fn bench(c: &mut Criterion) {
    c.bench_function("in_rust", |b| b.iter(|| {
        /* do things in Rust */
    }));

    c.c_benchmark("in_c", BenchSpec::new(r#"
        // do things in C
    "#));

    c.go_benchmark("in_go", BenchSpec::new(r#"
        // Do things in Go
    "#).with_imports(r#"
        // Import the Go modules you need
    "#));
}

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

Description

criterion_polyglot::CriterionPolyglotExt is an extension trait for criterion::Criterion and criterion::BenchmarkGroup that provides methods to benchmark non-Rust programming languages at the same time as Rust code so that graphs and performance statistics can be compared across polyglot implementations of the same data structure or algorithm.

criterion_polyglot provides benchmark harnesses for all the supported languages that can be filled in with a required, timed code fragment—the benchmark itself—and a variety of optional, untimed code fragments that initialize data for the benchmark or import modules / header files that the timed code may require. See the documentation for criterion_polyglot::BenchSpec for details.

Getting Started

If you haven't used Criterion.rs to benchmark your Rust code before, follow their project's Quickstart instructions, then come back here and follow the synopsis above and the APIt puj documentation to add polyglot benchmarks to your project.

Commit count: 0

cargo fmt