Skip to content

Commit

Permalink
Measure and print execution time of some commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kichalla committed Apr 1, 2019
1 parent ce04116 commit c7bcd3a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/BuildScriptGenerator/BaseBashBuildScript.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ then
then
echo
echo "Destination directory is not empty. Deleting its contents..."
START_TIME=$SECONDS
rm -rf "$DESTINATION_DIR"/*
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."
fi
fi

Expand All @@ -50,12 +53,14 @@ then
cd "$SOURCE_DIR"
echo
echo "Copying files to the intermediate directory..."
START_TIME=$SECONDS
excludedDirectories=""
{{ for excludedDir in DirectoriesToExcludeFromCopyToIntermediateDir }}
excludedDirectories+=" --exclude {{ excludedDir }}"
{{ end }}
rsync --delete -rt $excludedDirectories . "$INTERMEDIATE_DIR"
echo "Finished copying files to intermediate directory."
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."
SOURCE_DIR="$INTERMEDIATE_DIR"
fi

Expand Down Expand Up @@ -90,12 +95,14 @@ then
mkdir -p "$DESTINATION_DIR"
echo
echo "Copying files to destination directory '$DESTINATION_DIR'..."
START_TIME=$SECONDS
excludedDirectories=""
{{ for excludedDir in DirectoriesToExcludeFromCopyToBuildOutputDir }}
excludedDirectories+=" --exclude {{ excludedDir }}"
{{ end }}
rsync -rtE --links $excludedDirectories . "$DESTINATION_DIR"
echo "Finished copying files to destination directory."
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."
fi

{{ if PostBuildScriptPath | IsNotBlank }}
Expand All @@ -108,6 +115,7 @@ echo "{{ PostBuildScriptEpilogue }}"

{{ if ManifestFileName | IsNotBlank }}
MANIFEST_FILE={{ ManifestFileName }}
echo
echo "Removing existing manifest file"
rm -f "$DESTINATION_DIR/$MANIFEST_FILE"
{{ if BuildProperties != empty }}
Expand Down
10 changes: 8 additions & 2 deletions src/BuildScriptGenerator/Node/NodeBashBuildSnippet.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ then
fi

echo
echo "Installing production dependencies in '$prodDependencies'..."
echo "Installing production dependencies in '$prodModulesDirName'..."
echo "Running '{{ ProductionOnlyPackageInstallCommand }}'..."
echo
{{ ProductionOnlyPackageInstallCommand }}

echo
echo "Copying production dependencies from '$prodDependencies' to '$SOURCE_DIR'..."
echo "Copying production dependencies from '$prodModulesDirName' to '$SOURCE_DIR'..."
START_TIME=$SECONDS
rsync -rtE --links node_modules "$SOURCE_DIR"
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."
fi

cd "$SOURCE_DIR"
Expand Down Expand Up @@ -116,9 +119,12 @@ then
then
echo
echo Zipping existing 'node_modules' folder ...
START_TIME=$SECONDS
# Make the contents of the node_modules folder appear in the zip file, not the folder itself
cd node_modules
{{ CompressNodeModulesCommand }} ../$zippedModulesFileName .
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."
fi
fi
{{ end }}
18 changes: 17 additions & 1 deletion src/BuildScriptGenerator/Python/PythonBashBuildSnippet.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ source $VIRTUALENVIRONMENTNAME/bin/activate

if [ -e "requirements.txt" ]
then
echo
echo "Upgrading pip..."
START_TIME=$SECONDS
pip install --upgrade pip
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."

echo "Running pip install..."
pip install --prefer-binary -r requirements.txt | ts $TS_FMT
else
echo $REQS_NOT_FOUND_MSG
Expand All @@ -39,10 +46,13 @@ python_bin=python

if [ -e "requirements.txt" ]
then
echo
echo Running pip install...

START_TIME=$SECONDS
$pip install --prefer-binary -r requirements.txt --target="{{ PackagesDirectory }}" --upgrade | ts $TS_FMT
pipInstallExitCode=${PIPESTATUS[0]}
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."

if [[ $pipInstallExitCode != 0 ]]
then
Expand Down Expand Up @@ -78,8 +88,11 @@ then
echo
echo Content in source directory is a Django app
echo Running 'collectstatic' ...
START_TIME=$SECONDS
$python_bin manage.py collectstatic --noinput || EXIT_CODE=$? && true ;
echo "'collectstatic' exited with exit code $EXIT_CODE."
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."
fi
fi

Expand All @@ -100,9 +113,12 @@ then
then
echo
echo "Zipping existing '$VIRTUALENVIRONMENTNAME' folder..."
START_TIME=$SECONDS
# Make the contents of the '$VIRTUALENVIRONMENTNAME' folder appear in the zip file, not the folder itself
cd "$VIRTUALENVIRONMENTNAME"
tar -zcf ../$zippedVirtualEnvName .
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done in $ELAPSED_TIME sec(s)."
fi
fi
{{ end }}
Expand Down

0 comments on commit c7bcd3a

Please sign in to comment.