CriterionPolyglotExt

Trait CriterionPolyglotExt 

Source
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

  • id: &str - identifies the benchmark in Criterion’s output
  • spec: BenchSpec - defines the benchmark code, including non-benchmarked initialization code; see the BenchSpec documentation for detailed usage

Required Methods§

Source

fn python_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Benchmark Python 3 code

See trait-level documentation for argument descriptions.

Source

fn ruby_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Benchmark Ruby code

See trait-level documentation for argument descriptions.

Source

fn go_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Benchmark Go code

See trait-level documentation for argument descriptions.

Source

fn zig_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Benchmark Zig code

See trait-level documentation for argument descriptions.

Source

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§

Source

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.

Implementations on Foreign Types§

Source§

impl CriterionPolyglotExt for BenchmarkGroup<'_, WallTime>

Source§

fn python_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn ruby_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn zig_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn go_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn c_benchmark_with_builder( &mut self, id: &str, spec: BenchSpec<'_>, builder: Build, ) -> &mut Self

Source§

impl CriterionPolyglotExt for Criterion<WallTime>

Source§

fn python_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn ruby_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn zig_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn go_benchmark(&mut self, id: &str, spec: BenchSpec<'_>) -> &mut Self

Source§

fn c_benchmark_with_builder( &mut self, id: &str, spec: BenchSpec<'_>, builder: Build, ) -> &mut Self

Implementors§