pub trait CriterionPolyglotExt {
// Required methods
fn python_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self;
fn ruby_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self;
fn go_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self;
fn zig_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self;
fn c_benchmark_with_builder(
&mut self,
id: &str,
spec: BenchSpec<'_>,
builder: Build,
) -> &mut Self;
// Provided method
fn c_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self { ... }
}Expand description
CriterionPolyglotExt is an extension trait for criterion::Criterion and
criterion::BenchmarkGroup that provides benchmark methods for various non-Rust programming
languages.
§Function Parameters
Required Methods§
Sourcefn python_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
fn python_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
Benchmark Python 3 code
See trait-level documentation for argument descriptions.
Sourcefn ruby_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
fn ruby_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
Benchmark Ruby code
See trait-level documentation for argument descriptions.
Sourcefn go_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
fn go_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
Benchmark Go code
See trait-level documentation for argument descriptions.
Sourcefn zig_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
fn zig_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
Benchmark Zig code
See trait-level documentation for argument descriptions.
Sourcefn c_benchmark_with_builder(
&mut self,
id: &str,
spec: BenchSpec<'_>,
builder: Build,
) -> &mut Self
fn c_benchmark_with_builder( &mut self, id: &str, spec: BenchSpec<'_>, builder: Build, ) -> &mut Self
Benchmark C code, using a custom compiler
See trait-level documentation for details on the id and spec
arguments.
The builder argument takes an instance of cc::Build that can be
constructed to customize which C compiler is used to build the benchmark code and with
which options. To ensure you construct an instance of cc::Build that is compatible with
the version criterion-polyglot depends on, you may want to use the cc module
re-exported as criterion_polyglot::cc.
Provided Methods§
Sourcefn c_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
fn c_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self
Benchmark C code
See trait-level documentation for argument descriptions.
Uses the C compiler as configured by cc::Build::default(), then set to the same
optimization level as rustc (determined by the OPT_LEVEL environment variable)
Header files already included by the benchmarking harness are:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/errno.h>
#include <time.h>
#include <sys/time.h>and on macOS:
#include <mach/mach.h>
#include <mach/clock.h>Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.