Skip to content

Commit f646f50

Browse files
committed
Tools: Print how much time is being spent compiling a Tool
1 parent cb8bca4 commit f646f50

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Tools/Tools.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,31 @@ execute_tool () {
4242

4343
OS=$(uname -s)
4444

45+
# Time the initial build
46+
start_time=$(date +%s%N)
4547
call_make build
48+
initial_exit_code=$?
49+
end_time=$(date +%s%N)
50+
build_time=$(( (end_time - start_time) / 1000000000 ))
51+
build_time_frac=$(( (end_time - start_time) % 1000000000 / 1000000 ))
52+
printf "Time to compile \"${TOOL_NAME}\" tool: %d.%03d seconds\n" $build_time $build_time_frac
4653

47-
if [ $? -eq 0 ]; then
54+
if [ $initial_exit_code -eq 0 ]; then
4855
execute_tool "$@"
4956
else
5057
# It could have failed because of moved files, let's re-try after cleaning
5158
call_make clean
59+
# Time the clean and rebuild
60+
start_time=$(date +%s%N)
5261
call_make build
53-
if [ $? -eq 0 ]; then
62+
rebuild_exit_code=$?
63+
end_time=$(date +%s%N)
64+
rebuild_time=$(( (end_time - start_time) / 1000000000 ))
65+
rebuild_time_frac=$(( (end_time - start_time) % 1000000000 / 1000000 ))
66+
printf "Time to re-compile \"${TOOL_NAME}\" tool after clean: %d.%03d seconds\n" $rebuild_time $rebuild_time_frac
67+
if [ $rebuild_exit_code -eq 0 ]; then
5468
execute_tool "$@"
5569
else
56-
exit $?
70+
exit $rebuild_exit_code
5771
fi
5872
fi

0 commit comments

Comments
 (0)