Test rust-lang/regex example shootout-regex-dna
This commit is contained in:
parent
ee4927e069
commit
8691b8b8b6
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ perf.data.old
|
||||
/build_sysroot/sysroot_src
|
||||
/build_sysroot/Cargo.lock
|
||||
/rust
|
||||
/regex
|
||||
|
@ -1,34 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Requires the CHANNEL env var to be set to `debug` or `release.`
|
||||
|
||||
set -e
|
||||
cd $(dirname "$0")
|
||||
|
||||
pushd ../ >/dev/null
|
||||
source ./config.sh
|
||||
popd >/dev/null
|
||||
|
||||
# Cleanup for previous run
|
||||
# v Clean target dir except for build scripts and incremental cache
|
||||
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
|
||||
rm Cargo.lock 2>/dev/null || true
|
||||
rm -r sysroot 2>/dev/null || true
|
||||
|
||||
# FIXME find a better way to get the target triple
|
||||
unamestr=`uname`
|
||||
if [[ "$unamestr" == 'Linux' ]]; then
|
||||
TARGET_TRIPLE='x86_64-unknown-linux-gnu'
|
||||
elif [[ "$unamestr" == 'Darwin' ]]; then
|
||||
TARGET_TRIPLE='x86_64-apple-darwin'
|
||||
else
|
||||
echo "Unsupported os"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build libs
|
||||
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
||||
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
|
||||
if [[ "$1" == "--release" ]]; then
|
||||
channel='release'
|
||||
sysroot_channel='release'
|
||||
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
|
||||
else
|
||||
channel='debug'
|
||||
sysroot_channel='debug'
|
||||
cargo build --target $TARGET_TRIPLE
|
||||
fi
|
||||
|
||||
# Copy files to sysroot
|
||||
cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
||||
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
||||
cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
||||
|
14
cargo.sh
Executable file
14
cargo.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z $CHANNEL ]; then
|
||||
export CHANNEL='debug'
|
||||
fi
|
||||
|
||||
pushd $(dirname "$0") >/dev/null
|
||||
source config.sh
|
||||
popd >/dev/null
|
||||
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
cargo $cmd --target $TARGET_TRIPLE $@
|
@ -2,3 +2,4 @@
|
||||
set -e
|
||||
|
||||
rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/,Cargo.lock} perf.data{,.old}
|
||||
rm -rf regex/
|
||||
|
10
config.sh
10
config.sh
@ -10,14 +10,8 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$1" == "--release" ]]; then
|
||||
channel='release'
|
||||
cargo build --release
|
||||
else
|
||||
channel='debug'
|
||||
cargo build
|
||||
fi
|
||||
TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
|
||||
|
||||
export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
|
||||
export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
|
||||
RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out"
|
||||
export RUSTC_LOG=warn # display metadata load errors
|
||||
|
34
crate_patches/regex.patch
Normal file
34
crate_patches/regex.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From febff2a8c639efb5de1e1b4758cdb473847d80ce Mon Sep 17 00:00:00 2001
|
||||
From: bjorn3 <bjorn3@users.noreply.github.com>
|
||||
Date: Tue, 30 Jul 2019 12:12:37 +0200
|
||||
Subject: [PATCH] Disable threads in shootout-regex-dna example
|
||||
|
||||
---
|
||||
examples/shootout-regex-dna.rs | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/examples/shootout-regex-dna.rs b/examples/shootout-regex-dna.rs
|
||||
index 2171bb3..37382f8 100644
|
||||
--- a/examples/shootout-regex-dna.rs
|
||||
+++ b/examples/shootout-regex-dna.rs
|
||||
@@ -37,7 +37,7 @@ fn main() {
|
||||
for variant in variants {
|
||||
let seq = seq_arc.clone();
|
||||
let restr = variant.to_string();
|
||||
- let future = thread::spawn(move || variant.find_iter(&seq).count());
|
||||
+ let future = variant.find_iter(&seq).count();
|
||||
counts.push((restr, future));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ fn main() {
|
||||
}
|
||||
|
||||
for (variant, count) in counts {
|
||||
- println!("{} {}", variant, count.join().unwrap());
|
||||
+ println!("{} {}", variant, count);
|
||||
}
|
||||
println!("\n{}\n{}\n{}", ilen, clen, seq.len());
|
||||
}
|
||||
--
|
||||
2.11.0
|
||||
|
@ -4,3 +4,10 @@ set -e
|
||||
rustup component add rust-src
|
||||
./build_sysroot/prepare_sysroot_src.sh
|
||||
cargo install hyperfine || echo "Skipping hyperfine install"
|
||||
|
||||
git clone https://github.com/rust-lang/regex.git || echo "rust-lang/regex has already been cloned"
|
||||
pushd regex
|
||||
git checkout -- .
|
||||
git checkout 341f207c1071f7290e3f228c710817c280c8dca1
|
||||
git apply ../crate_patches/regex.patch
|
||||
popd
|
||||
|
22
test.sh
22
test.sh
@ -1,4 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$1" == "--release" ]]; then
|
||||
export CHANNEL='release'
|
||||
cargo build --release
|
||||
else
|
||||
export CHANNEL='debug'
|
||||
cargo build
|
||||
fi
|
||||
|
||||
source config.sh
|
||||
|
||||
rm -r target/out || true
|
||||
@ -39,6 +48,19 @@ $RUSTC example/mod_bench.rs --crate-type bin
|
||||
#echo "[BUILD] sysroot in release mode"
|
||||
#./build_sysroot/build_sysroot.sh --release
|
||||
|
||||
pushd regex
|
||||
echo "[TEST] rust-lang/regex example shootout-regex-dna"
|
||||
../cargo.sh clean
|
||||
# Make sure `[codegen mono items] start` doesn't poison the diff
|
||||
../cargo.sh build --example shootout-regex-dna
|
||||
cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt
|
||||
diff -u res.txt examples/regexdna-output.txt
|
||||
|
||||
# FIXME compile libtest
|
||||
# echo "[TEST] rust-lang/regex standalone tests"
|
||||
# ../cargo.sh test
|
||||
popd
|
||||
|
||||
COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
|
||||
COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort"
|
||||
COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort"
|
||||
|
Loading…
Reference in New Issue
Block a user