performance test adjustments

This commit is contained in:
Malte Tammena 2024-04-20 14:09:41 +02:00
parent 4590221966
commit 0e633b9a86
3 changed files with 94 additions and 77 deletions

View file

@ -198,6 +198,7 @@
pkgs.shellcheck
pkgs.shfmt
pkgs.nodejs
pkgs.hyperfine
self'.packages.aspforaba
];
};

View file

@ -20,27 +20,43 @@ print_help_and_exit() {
exit 1
}
format_time() {
COMMAND="$1"
FILE="$2"
mean=$(jq ".results[] | select(.command == \"$COMMAND\") | (.mean * 1000)" "$FILE")
stddev=$(jq ".results[] | select(.command == \"$COMMAND\") | (.stddev * 1000)" "$FILE")
printf "%7.3f±%7.3fms" "$mean" "$stddev"
}
run_dc_co() {
OUTPUT_DIR=${OUTPUT_DIR:-$(mktemp -d)}
mkdir -p "$OUTPUT_DIR"
JSON_FILE="$OUTPUT_DIR/$(basename "$ABA_FILE")-hyperfine.json"
# Restrict memory to 20GB
ulimit -v 20000000
if [ -z "$ADDITIONAL_ARG" ]; then
print_help_and_exit "Parameter --arg is missing!"
fi
if [ -z "$ABA_FILE" ]; then
print_help_and_exit "Parameter --file is missing!"
fi
printf "%40s " "$(basename "$ABA_FILE")"
TIMEFORMAT='{"wall":"%E","system":"%S","user":"%U"}'
our_result=$(command time -f "$TIMEFORMAT" -o /tmp/aba2sat-time "$ABA2SAT" --file "$ABA_FILE" dc-co --query "$ADDITIONAL_ARG")
other_result=$(command time -f "$TIMEFORMAT" -o /tmp/aspforaba-time "$ASPFORABA" --file "$ABA_FILE" --problem DC-CO --query "$ADDITIONAL_ARG")
printf "===== %s ==== " "$(basename "$ABA_FILE")"
our_result=$("$ABA2SAT" --file "$ABA_FILE" dc-co --query "$ADDITIONAL_ARG" | tee "$OUTPUT_DIR/$(basename "$ABA_FILE")-aba2sat-result")
other_result=$("$ASPFORABA" --file "$ABA_FILE" --problem DC-CO --query "$ADDITIONAL_ARG" | tee "$OUTPUT_DIR/$(basename "$ABA_FILE")-aspforaba-result")
$HYPERFINE --shell=none \
--export-json "$JSON_FILE" \
--command-name "aba2sat" \
"$ABA2SAT --file \"$ABA_FILE\" dc-co --query \"$ADDITIONAL_ARG\"" \
--command-name "aspforaba" \
"$ASPFORABA --file \"$ABA_FILE\" --problem DC-CO --query \"$ADDITIONAL_ARG\"" 1>/dev/null 2>&1
if [ "$our_result" != "$other_result" ]; then
printf "❌\n"
printf "%40s:%s\n" "arg" "$ADDITIONAL_ARG"
printf "%40s:%40s %s\n" "Ours" "$our_result" "$(jq --compact-output --color-output </tmp/aba2sat-time)"
printf "%40s:%40s %s\n" "Theirs" "$other_result" "$(jq --compact-output --color-output </tmp/aspforaba-time)"
else
printf "✅\n"
printf "%40s:%40s %s\n" "Ours" "$our_result" "$(jq --compact-output --color-output </tmp/aba2sat-time)"
printf "%40s:%40s %s\n" "Theirs" "$other_result" "$(jq --compact-output --color-output </tmp/aspforaba-time)"
fi
printf "Argument: %s\n" "$ADDITIONAL_ARG"
printf "Our: %3s %30s\n" "$our_result" "$(format_time "aba2sat" "$JSON_FILE")"
printf "Their: %3s %30s\n" "$other_result" "$(format_time "aspforaba" "$JSON_FILE")"
}
POSITIONAL_ARGS=()
@ -49,82 +65,83 @@ ABA2SAT=result/bin/aba2sat
ABA_FILE=
ABA_FILE_DIR=
ABA_FILE_EXT=aba
HYPERFINE=hyperfine
PROBLEM=
ADDITIONAL_ARG=
while [[ $# -gt 0 ]]; do
case $1 in
-h | --help)
print_help_and_exit
;;
--aspforaba)
shift
ASPFORABA=$1
shift
;;
-p | --problem)
shift
PROBLEM=$1
shift
;;
-f | --file)
if [ -n "$ABA_FILE_DIR" ]; then
print_help_and_exit "Parameters --file and --files-from cannot be mixed"
fi
shift
ABA_FILE=$1
shift
;;
--files-from)
if [ -n "$ABA_FILE" ]; then
print_help_and_exit "Parameters --file and --files-from cannot be mixed"
fi
if [ -n "$ADDITIONAL_ARG" ]; then
print_help_and_exit "Parameters --arg and --files-from cannot be mixed"
fi
shift
ABA_FILE_DIR=$1
shift
;;
-a | --arg)
if [ -n "$ABA_FILE_DIR" ]; then
print_help_and_exit "Parameters --arg and --files-from cannot be mixed"
fi
shift
ADDITIONAL_ARG=$1
shift
;;
--aba2sat)
shift
ABA2SAT=$1
shift
;;
-*)
echo "Unknown option $1"
print_help_and_exit
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
-h | --help)
print_help_and_exit
;;
--aspforaba)
shift
ASPFORABA=$1
shift
;;
-p | --problem)
shift
PROBLEM=$1
shift
;;
-f | --file)
if [ -n "$ABA_FILE_DIR" ]; then
print_help_and_exit "Parameters --file and --files-from cannot be mixed"
fi
shift
ABA_FILE=$1
shift
;;
--files-from)
if [ -n "$ABA_FILE" ]; then
print_help_and_exit "Parameters --file and --files-from cannot be mixed"
fi
if [ -n "$ADDITIONAL_ARG" ]; then
print_help_and_exit "Parameters --arg and --files-from cannot be mixed"
fi
shift
ABA_FILE_DIR=$1
shift
;;
-a | --arg)
if [ -n "$ABA_FILE_DIR" ]; then
print_help_and_exit "Parameters --arg and --files-from cannot be mixed"
fi
shift
ADDITIONAL_ARG=$1
shift
;;
--aba2sat)
shift
ABA2SAT=$1
shift
;;
-*)
echo "Unknown option $1"
print_help_and_exit
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
case "$PROBLEM" in
dc-co | DC-CO)
if [ -n "$ABA_FILE_DIR" ]; then
# run for every file found in the directory
for file in "$ABA_FILE_DIR"/*."$ABA_FILE_EXT"; do
ABA_FILE="$file" ADDITIONAL_ARG="$(cat "$file.asm")" run_dc_co
done
else
# run for the single configured file
run_dc_co
fi
;;
*)
print_help_and_exit "Problem $PROBLEM is not supported"
;;
dc-co | DC-CO)
if [ -n "$ABA_FILE_DIR" ]; then
# run for every file found in the directory
for file in "$ABA_FILE_DIR"/*."$ABA_FILE_EXT"; do
ABA_FILE="$file" ADDITIONAL_ARG="$(cat "$file.asm")" run_dc_co
done
else
# run for the single configured file
run_dc_co
fi
;;
*)
print_help_and_exit "Problem $PROBLEM is not supported"
;;
esac

View file

@ -219,7 +219,6 @@ fn calculate_loops_and_their_support(aba: &Aba) -> Vec<r#Loop> {
std::ops::ControlFlow::Continue(())
}
});
eprintln!("{}", loops.len());
loops
}