criterion-polyglot 0.1.0

An extension trait for criterion providing benchmark methods for various non-Rust programming languages
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::process::Command;

use crate::{helper::{get_criterion_env_var, make_spec_tempfile}, runner::CommunicatingBenchmark, BenchSpec};

const HARNESS: &str = include_str!("harness.rb.in");
const SOURCE_EXTENSION: &str = ".rb";

pub fn spawn(spec: BenchSpec) -> CommunicatingBenchmark {
    let bench_file = make_spec_tempfile(self::SOURCE_EXTENSION, HARNESS, &spec);
    let ruby_path = get_criterion_env_var("RUBY", "ruby");
    let mut command = Command::new(ruby_path);
    command.arg(&bench_file);

    CommunicatingBenchmark::start("Ruby", command, Some(bench_file))
}