mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
61 lines
2.2 KiB
Bash
61 lines
2.2 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
#------------------------------------------------------------------------------
|
||
|
# Bash script to run optimizer performance tests.
|
||
|
# ------------------------------------------------------------------------------
|
||
|
# This file is part of solidity.
|
||
|
#
|
||
|
# solidity is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation, either version 3 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
# solidity is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with solidity. If not, see <http://www.gnu.org/licenses/>
|
||
|
#
|
||
|
# (c) 2022 solidity contributors.
|
||
|
#------------------------------------------------------------------------------
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
REPO_ROOT=$(cd "$(dirname "$0")/../../" && pwd)
|
||
|
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
|
||
|
|
||
|
result_legacy_file=$(mktemp -t benchmark-legacy-XXXXXX.txt)
|
||
|
result_via_ir_file=$(mktemp -t benchmark-via-ir-XXXXXX.txt)
|
||
|
|
||
|
function cleanup() {
|
||
|
rm "${result_legacy_file}"
|
||
|
rm "${result_via_ir_file}"
|
||
|
exit
|
||
|
}
|
||
|
|
||
|
trap cleanup SIGINT SIGTERM
|
||
|
|
||
|
solc="${SOLIDITY_BUILD_DIR}/solc/solc"
|
||
|
benchmarks_dir="${REPO_ROOT}/test/benchmarks"
|
||
|
chains_sol="${benchmarks_dir}/chains.sol"
|
||
|
time_bin_path=$(type -P time)
|
||
|
|
||
|
solc_command_legacy=("${solc}" --optimize --bin "${chains_sol}")
|
||
|
solc_command_via_ir=("${solc}" --via-ir --optimize --bin "${chains_sol}")
|
||
|
|
||
|
"${time_bin_path}" --output "${result_legacy_file}" --format "%e" "${solc_command_legacy[@]}" >/dev/null
|
||
|
"${time_bin_path}" --output "${result_via_ir_file}" --format "%e" "${solc_command_via_ir[@]}" >/dev/null
|
||
|
|
||
|
time_legacy=$(<"${result_legacy_file}")
|
||
|
time_via_ir=$(<"${result_via_ir_file}")
|
||
|
|
||
|
echo "======================================================="
|
||
|
echo "legacy pipeline took ${time_legacy} seconds to execute."
|
||
|
echo "via-ir pipeline took ${time_via_ir} seconds to execute."
|
||
|
echo "======================================================="
|
||
|
|
||
|
cleanup
|
||
|
|