Skip to content

Commit

Permalink
bench: remove D and C++ regex engines
Browse files Browse the repository at this point in the history
Neither of them were particularly competitive and they make building the
benchmark harness more trouble than it's worth.
  • Loading branch information
BurntSushi committed Jul 1, 2022
1 parent 2f23f60 commit ea525cd
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 688 deletions.
8 changes: 0 additions & 8 deletions bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ bench = false
re-pcre1 = ["libpcre-sys"]
re-pcre2 = []
re-onig = ["onig"]
re-stdcpp = []
libcxx = []
re-boost = []
re-re2 = []
re-dphobos = []
re-dphobos-dmd = ["re-dphobos"]
re-dphobos-dmd-ct = ["re-dphobos-dmd"]
re-dphobos-ldc = ["re-dphobos"]
re-dphobos-ldc-ct = ["re-dphobos-ldc"]
re-rust = []
re-rust-bytes = []
re-tcl = []
Expand Down
109 changes: 0 additions & 109 deletions bench/build.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,9 @@
use std::env;
use std::process;

fn main() {
if env::var("CARGO_FEATURE_RE_PCRE2").is_ok() {
pkg_config::probe_library("libpcre2-8").unwrap();
}
if env::var("CARGO_FEATURE_RE_STDCPP").is_ok() {
// stdcpp is a C++ library, so we need to compile our shim layer.
if !env::var("CARGO_FEATURE_LIBCXX").is_ok() {
// use default stdlib
cc::Build::new()
.cpp(true)
.file("src/ffi/stdcpp.cpp")
.compile("libcstdcpp.a");
} else {
// use libc++ stdlib
cc::Build::new()
.cpp(true)
.file("src/ffi/stdcpp.cpp")
.compiler("clang++")
.cpp_link_stdlib("c++")
.cpp_set_stdlib("c++")
.compile("libcstdcpp.a");
}
}
if env::var("CARGO_FEATURE_RE_BOOST").is_ok() {
// stdcpp is a C++ library, so we need to compile our shim layer.
cc::Build::new()
.cpp(true)
.file("src/ffi/stdcpp.cpp")
.define("USE_BOOST", None)
.compile("libcboost.a");
println!("cargo:rustc-link-lib=boost_regex");
}
if env::var("CARGO_FEATURE_RE_RE2").is_ok() {
// RE2 is a C++ library, so we need to compile our shim layer.
cc::Build::new()
Expand All @@ -46,84 +17,4 @@ fn main() {
if env::var("CARGO_FEATURE_RE_TCL").is_ok() {
pkg_config::probe_library("tcl").unwrap();
}

if env::var("CARGO_FEATURE_RE_DPHOBOS_DMD").is_ok() {
process::Command::new("dmd")
.arg("--version")
.stdout(process::Stdio::null())
.stderr(process::Stdio::null())
.spawn()
.unwrap();

let out_dir = env::var("OUT_DIR").unwrap();
let out_file = &format!("-of={}/libdphobos-dmd.a", out_dir);
let is_compile_time =
env::var("CARGO_FEATURE_RE_DPHOBOS_DMD_CT").is_ok();
let extra_args =
if is_compile_time { vec!["-version=CtRegex"] } else { vec![] };

let res = process::Command::new("dmd")
.arg("-w")
.arg("-lib")
.arg("-O")
.arg("-release")
.arg("-inline")
.arg("-Isrc/ffi")
.args(extra_args)
.arg("src/ffi/d_phobos.d")
.arg("src/ffi/d_phobos_ct.d")
.arg(out_file)
.output()
.expect("unable to compile dphobos-regex (dmd)");

if !res.status.success() {
println!("{}", String::from_utf8_lossy(&res.stderr));
}
assert!(res.status.success());

println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=dphobos-dmd");
println!("cargo:rustc-link-lib=phobos2");
}

if env::var("CARGO_FEATURE_RE_DPHOBOS_LDC").is_ok() {
process::Command::new("ldc")
.arg("--version")
.stdout(process::Stdio::null())
.stderr(process::Stdio::null())
.spawn()
.unwrap();

let out_dir = env::var("OUT_DIR").unwrap();
let out_file = &format!("-of={}/libdphobos-ldc.a", out_dir);

let is_compile_time =
env::var("CARGO_FEATURE_RE_DPHOBOS_LDC_CT").is_ok();
let extra_args =
if is_compile_time { vec!["-d-version=CtRegex"] } else { vec![] };

let res = process::Command::new("ldc")
.arg("-w")
.arg("-lib")
.arg("-O3")
.arg("-release")
.arg("-mcpu=native")
.arg("-Isrc/ffi")
.args(extra_args)
.arg("src/ffi/d_phobos.d")
.arg("src/ffi/d_phobos_ct.d")
.arg(out_file)
.output()
.expect("unable to compile dphobos-regex (ldc)");

if !res.status.success() {
println!("{}", String::from_utf8_lossy(&res.stderr));
}
assert!(res.status.success());

println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=dphobos-ldc");
println!("cargo:rustc-link-lib=druntime-ldc");
println!("cargo:rustc-link-lib=phobos2-ldc");
}
}
23 changes: 1 addition & 22 deletions bench/run
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

usage() {
echo "Usage: $(basename $0) [dphobos-dmd | dphobos-ldc | dphobos-dmd-ct | dphobos-ldc-ct | rust | rust-bytes | pcre1 | pcre2 | stdcpp | stdcpp-libcxx | boost | re2 | onig | tcl ]" >&2
echo "Usage: $(basename $0) [rust | rust-bytes | pcre1 | pcre2 | re2 | onig | tcl ]" >&2
exit 1
}

Expand All @@ -12,33 +12,12 @@ fi
which="$1"
shift
case $which in
dphobos-dmd)
exec cargo bench --bench bench --features re-dphobos-dmd "$@"
;;
dphobos-ldc)
exec cargo bench --bench bench --features re-dphobos-ldc "$@"
;;
dphobos-dmd-ct)
exec cargo bench --bench bench --features re-dphobos-dmd-ct "$@"
;;
dphobos-ldc-ct)
exec cargo bench --bench bench --features re-dphobos-ldc-ct "$@"
;;
rust)
exec cargo bench --bench bench --features re-rust "$@"
;;
rust-bytes)
exec cargo bench --bench bench --features re-rust-bytes "$@"
;;
stdcpp)
exec cargo bench --bench bench --features re-stdcpp "$@"
;;
stdcpp-libcxx)
exec cargo bench --bench bench --features 're-stdcpp libcxx' "$@"
;;
boost)
exec cargo bench --bench bench --features re-boost "$@"
;;
re2)
exec cargo bench --bench bench --features re-re2 "$@"
;;
Expand Down
7 changes: 0 additions & 7 deletions bench/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ cfg_if! {
pub use regex::bytes::{Regex, RegexSet};
} else if #[cfg(feature = "re-re2")] {
pub use ffi::re2::Regex;
} else if #[cfg(feature = "re-dphobos")] {
pub use ffi::d_phobos::Regex;
} else if #[cfg(feature = "re-pcre2")] {
pub use ffi::pcre2::Regex;
} else if #[cfg(any(feature = "re-stdcpp", feature = "re-boost"))] {
pub use ffi::stdcpp::Regex;
} else if #[cfg(feature = "re-tcl")] {
pub use ffi::tcl::Regex;
} else {
Expand Down Expand Up @@ -299,10 +295,7 @@ cfg_if! {
feature = "re-rust",
feature = "re-rust-bytes",
feature = "re-re2",
feature = "re-dphobos",
feature = "re-pcre2",
feature = "re-stdcpp",
feature = "re-boost",
feature = "re-tcl"
))] {
mod ffi;
Expand Down
63 changes: 0 additions & 63 deletions bench/src/ffi/d_phobos.d

This file was deleted.

102 changes: 0 additions & 102 deletions bench/src/ffi/d_phobos.rs

This file was deleted.

0 comments on commit ea525cd

Please sign in to comment.