env setup (#6)

This commit is contained in:
zhenfei
2022-04-20 17:10:25 -04:00
committed by GitHub
parent 5b2265b633
commit 9d4d178455
25 changed files with 605 additions and 0 deletions

37
scripts/run_benchmarks.m4 Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# m4_ignore(
echo "This is just a script template, not the script (yet) - pass it to 'argbash' to fix this." >&2
exit 11 #)Created by argbash-init v2.10.0
# ARG_OPTIONAL_BOOLEAN([asm])
# ARG_OPTIONAL_BOOLEAN([multi_threads])
# ARG_HELP([<Hyperplonk benchmarks>])
# ARGBASH_GO
# [ <-- needed because of Argbash
if [ "$_arg_multi_threads" = on ]
then
echo "Multi-threads: ON"
# Do nothing
else
echo "Multi-threads: OFF"
export RAYON_NUM_THREADS=1
fi
if [ "$_arg_asm" = on ]
then
echo "Asm feature: ON"
export RUSTFLAGS="-C target-feature=+bmi2,+adx"
else
echo "Asm feature: OFF"
# Do nothing
fi
# Run the benchmark binary
cargo +nightly bench
# ^^^ TERMINATE YOUR CODE BEFORE THE BOTTOM ARGBASH MARKER ^^^
# ] <-- needed because of Argbash

106
scripts/run_benchmarks.sh Executable file
View File

@@ -0,0 +1,106 @@
#!/usr/bin/env bash
# Created by argbash-init v2.10.0
# ARG_OPTIONAL_BOOLEAN([asm])
# ARG_OPTIONAL_BOOLEAN([multi_threads])
# ARG_HELP([<Hyperplonk benchmarks>])
# ARGBASH_GO()
# needed because of Argbash --> m4_ignore([
### START OF CODE GENERATED BY Argbash v2.10.0 one line above ###
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
die()
{
local _ret="${2:-1}"
test "${_PRINT_HELP:-no}" = yes && print_help >&2
echo "$1" >&2
exit "${_ret}"
}
begins_with_short_option()
{
local first_option all_short_options='h'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}
# THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_asm="off"
_arg_multi_threads="off"
print_help()
{
printf '%s\n' "<Hyperplonk benchmarks>"
printf 'Usage: %s [--(no-)asm] [--(no-)multi_threads] [-h|--help]\n' "$0"
printf '\t%s\n' "-h, --help: Prints help"
}
parse_commandline()
{
while test $# -gt 0
do
_key="$1"
case "$_key" in
--no-asm|--asm)
_arg_asm="on"
test "${1:0:5}" = "--no-" && _arg_asm="off"
;;
--no-multi_threads|--multi_threads)
_arg_multi_threads="on"
test "${1:0:5}" = "--no-" && _arg_multi_threads="off"
;;
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
}
parse_commandline "$@"
# OTHER STUFF GENERATED BY Argbash
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
cargo clean
if [ "$_arg_multi_threads" = on ]
then
echo "Multi-threads: ON"
# Do nothing
else
echo "Multi-threads: OFF"
export RAYON_NUM_THREADS=1
fi
if [ "$_arg_asm" = on ]
then
echo "Asm feature: ON"
export RUSTFLAGS="-C target-feature=+bmi2,+adx"
else
echo "Asm feature: OFF"
# Do nothing
fi
# Run the benchmark binary
cargo bench
# ^^^ TERMINATE YOUR CODE BEFORE THE BOTTOM ARGBASH MARKER ^^^
# ] <-- needed because of Argbash

7
scripts/run_tests.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# We want the code to panic if there is an integer overflow
export RUSTFLAGS="-C overflow-checks=on"
cargo test --release -- -Zunstable-options --report-time

16
scripts/test_coverage.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env nix-shell
#!nix-shell ../nix/nightly.nix -i bash
set -o xtrace
IGNORED_FILES="--ignore **/errors.rs\
--ignore **/src/bin/*\
--ignore transactions/src/parameters.rs\
--ignore transactions/src/bench_utils/*\
"
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=3 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests"
export RUSTDOCFLAGS=""
rm -vf ./target/**/*.gcda
cargo build
cargo test --lib
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing $IGNORED_FILES -o ./target/debug/coverage/
echo "Coverage report available at target/debug/coverage/index.html."