Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,25 @@ function gnu_grep
grep "$@"
fi
}

function time_to_json_file
{
local output_file="$1"
local cmd=("${@:2}")
(( $# >= 2 )) || assertFail

# $TIMEFORMAT is the format used by built-in `time`. Description is in `man bash`.
local original_timeformat="$TIMEFORMAT"
TIMEFORMAT='{"real": %R, "user": %U, "sys": %S}'

# We temporarily use descriptors 3 and 4 to preserve stdout and stderr of the original command.
# This allows us to store `time`'s own stderr in a file. Then we restore initial descriptors.
{
{
time { "${cmd[@]}" 1>&3 2>&4; }
} 2> "$output_file"
} 3>&1 4>&2

# Restore original format so that it does not spill outside of the function.
TIMEFORMAT="$original_timeformat"
}
14 changes: 11 additions & 3 deletions scripts/externalTests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,14 @@ function compile_and_run_test
[[ $preset != *" "* ]] || assertFail "Preset names must not contain spaces."

printLog "Running compile function..."
time $compile_fn
$verify_fn "$SOLCVERSION_SHORT" "$SOLCVERSION"
time_to_json_file "$(compilation_time_report_path "$preset")" "$compile_fn"
"$verify_fn" "$SOLCVERSION_SHORT" "$SOLCVERSION"

if [[ "$COMPILE_ONLY" == 1 || " $compile_only_presets " == *" $preset "* ]]; then
printLog "Skipping test function..."
else
printLog "Running test function..."
$test_fn
"$test_fn"
fi
}

Expand Down Expand Up @@ -572,6 +572,13 @@ function gas_report_path
echo "${DIR}/gas-report-${preset}.rst"
}

function compilation_time_report_path
{
local preset="$1"

echo "${DIR}/compilation-time-report-${preset}.json"
}

function gas_report_to_json
{
cat - | "${REPO_ROOT}/scripts/externalTests/parse_eth_gas_report.py" | jq '{gas: .}'
Expand Down Expand Up @@ -679,5 +686,6 @@ function store_benchmark_report

"bytecode_size_json_from_${framework}_artifacts" | combine_artifact_json
project_info_json "$project_url"
echo "{\"compilation_time\": $(cat "$(compilation_time_report_path "$preset")")}"
} | jq --slurp "{\"${project_name}\": {\"${preset}\": add}}" --indent 4 --sort-keys > "$output_file"
}