arnaucube
arnaucube/hyperplonkPublic Self-hosted repository
hyperplonk/scripts/run_benchmarks.sh
scripts/run_benchmarks.shRaw
  1#!/usr/bin/env bash
  2
  3# Created by argbash-init v2.10.0
  4# ARG_OPTIONAL_BOOLEAN([asm])
  5# ARG_OPTIONAL_BOOLEAN([multi_threads])
  6# ARG_HELP([<Hyperplonk benchmarks>])
  7# ARGBASH_GO()
  8# needed because of Argbash --> m4_ignore([
  9### START OF CODE GENERATED BY Argbash v2.10.0 one line above ###
 10# Argbash is a bash code generator used to get arguments parsing right.
 11# Argbash is FREE SOFTWARE, see https://argbash.io for more info
 12
 13
 14die()
 15{
 16	local _ret="${2:-1}"
 17	test "${_PRINT_HELP:-no}" = yes && print_help >&2
 18	echo "$1" >&2
 19	exit "${_ret}"
 20}
 21
 22
 23begins_with_short_option()
 24{
 25	local first_option all_short_options='h'
 26	first_option="${1:0:1}"
 27	test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
 28}
 29
 30# THE DEFAULTS INITIALIZATION - OPTIONALS
 31_arg_asm="off"
 32_arg_multi_threads="off"
 33
 34
 35print_help()
 36{
 37	printf '%s\n' "<Hyperplonk benchmarks>"
 38	printf 'Usage: %s [--(no-)asm] [--(no-)multi_threads] [-h|--help]\n' "$0"
 39	printf '\t%s\n' "-h, --help: Prints help"
 40}
 41
 42
 43parse_commandline()
 44{
 45	while test $# -gt 0
 46	do
 47		_key="$1"
 48		case "$_key" in
 49			--no-asm|--asm)
 50				_arg_asm="on"
 51				test "${1:0:5}" = "--no-" && _arg_asm="off"
 52				;;
 53			--no-multi_threads|--multi_threads)
 54				_arg_multi_threads="on"
 55				test "${1:0:5}" = "--no-" && _arg_multi_threads="off"
 56				;;
 57			-h|--help)
 58				print_help
 59				exit 0
 60				;;
 61			-h*)
 62				print_help
 63				exit 0
 64				;;
 65			*)
 66				_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
 67				;;
 68		esac
 69		shift
 70	done
 71}
 72
 73parse_commandline "$@"
 74
 75# OTHER STUFF GENERATED BY Argbash
 76
 77### END OF CODE GENERATED BY Argbash (sortof) ### ])
 78# [ <-- needed because of Argbash
 79
 80cargo clean
 81
 82if [ "$_arg_multi_threads" = on ]
 83then
 84  echo "Multi-threads: ON"
 85  # Do nothing
 86else
 87  echo "Multi-threads: OFF"
 88  export RAYON_NUM_THREADS=1
 89fi
 90
 91if [ "$_arg_asm" = on ]
 92then
 93  echo "Asm feature: ON"
 94  export RUSTFLAGS="-C target-feature=+bmi2,+adx"
 95else
 96  echo "Asm feature: OFF"
 97  # Do nothing
 98fi
 99
100# Run the benchmark binary
101cargo bench
102
103
104# ^^^  TERMINATE YOUR CODE BEFORE THE BOTTOM ARGBASH MARKER  ^^^
105
106# ] <-- needed because of Argbash