Add optimizor club benchmark.

This commit is contained in:
chriseth 2022-11-29 11:33:18 +01:00 committed by Nikola Matic
parent 5e74e95b67
commit 0cf7236729
2 changed files with 29 additions and 20 deletions

View File

@ -344,7 +344,7 @@ library NFTSVG {
'<g font-family="\'Courier New\', monospace" font-size="12" fill="#fff">' '<g font-family="\'Courier New\', monospace" font-size="12" fill="#fff">'
'<g style="transform:translate(29px, 384px)">' '<rect width="', '<g style="transform:translate(29px, 384px)">' '<rect width="',
LibString.toString(uint256(7 * (str1length + 4))), LibString.toString(uint256(7 * (str1length + 4))),
'" height="26" rx="8" ry="8" fill="rgba(0,0,0,0.6)"/>' '<text x="12" y="17"><tspan fill="#999">ID: </tspan>', string.concat('" height="26" rx="8" ry="8" fill="rgba(0,0,0,0.6)"/>' '<text x="12" y="17"><tspan fill="#999">ID: </tspan>'),
tokenId, tokenId,
"</text></g>" '<g style="transform:translate(29px, 414px)">' '<rect width="', "</text></g>" '<g style="transform:translate(29px, 414px)">' '<rect width="',
LibString.toString(uint256(7 * (str2length + 4))), LibString.toString(uint256(7 * (str2length + 4))),

View File

@ -26,41 +26,50 @@ set -euo pipefail
REPO_ROOT=$(cd "$(dirname "$0")/../../" && pwd) REPO_ROOT=$(cd "$(dirname "$0")/../../" && pwd)
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build} SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
result_legacy_file=$(mktemp -t benchmark-legacy-XXXXXX.txt) output_dir=$(mktemp -d -t solc-benchmark-XXXXXX)
result_via_ir_file=$(mktemp -t benchmark-via-ir-XXXXXX.txt) result_legacy_file="${output_dir}/benchmark-legacy.txt"
result_via_ir_file="${output_dir}/benchmark-via-ir.txt"
warnings_and_errors_file="${output_dir}/benchmark-warn-err.txt"
function cleanup() { function cleanup() {
rm "${result_legacy_file}" rm -r "${output_dir}"
rm "${result_via_ir_file}" exit
exit
} }
trap cleanup SIGINT SIGTERM trap cleanup SIGINT SIGTERM
solc="${SOLIDITY_BUILD_DIR}/solc/solc" solc="${SOLIDITY_BUILD_DIR}/solc/solc"
benchmarks_dir="${REPO_ROOT}/test/benchmarks" benchmarks_dir="${REPO_ROOT}/test/benchmarks"
benchmarks=("chains.sol" "OptimizorClub.sol")
time_bin_path=$(type -P time) time_bin_path=$(type -P time)
for input_file in "chains.sol" "OptimizorClub.sol" for input_file in "${benchmarks[@]}"
do do
input_path="${benchmarks_dir}/${input_file}" input_path="${benchmarks_dir}/${input_file}"
solc_command_legacy=("${solc}" --optimize --bin "${input_path}") solc_command_legacy=("${solc}" --optimize --bin --color "${input_path}")
solc_command_via_ir=("${solc}" --via-ir --optimize --bin "${input_path}") solc_command_via_ir=("${solc}" --via-ir --optimize --bin --color "${input_path}")
"${time_bin_path}" --output "${result_legacy_file}" --format "%e" "${solc_command_legacy[@]}" >/dev/null # Legacy can fail.
"${time_bin_path}" --output "${result_via_ir_file}" --format "%e" "${solc_command_via_ir[@]}" >/dev/null "${time_bin_path}" --output "${result_legacy_file}" --format "%e" "${solc_command_legacy[@]}" >/dev/null 2>>"${warnings_and_errors_file}"
"${time_bin_path}" --output "${result_via_ir_file}" --format "%e" "${solc_command_via_ir[@]}" >/dev/null 2>>"${warnings_and_errors_file}"
time_legacy=$(<"${result_legacy_file}") time_legacy=$(<"${result_legacy_file}")
time_via_ir=$(<"${result_via_ir_file}") time_via_ir=$(<"${result_via_ir_file}")
echo "=======================================================" echo "======================================================="
echo " ${input_file}" echo " ${input_file}"
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "legacy pipeline took ${time_legacy} seconds to execute." echo "legacy pipeline took ${time_legacy} seconds to execute."
echo "via-ir pipeline took ${time_via_ir} seconds to execute." echo "via-ir pipeline took ${time_via_ir} seconds to execute."
echo "=======================================================" echo "======================================================="
done done
echo
echo "======================================================="
echo "Warnings and errors generated during run:"
echo "======================================================="
echo "$(<"${warnings_and_errors_file}")"
cleanup cleanup