Measure loading time of scripts

This commit is contained in:
lachtan
2023-01-28 05:16:10 -01:00
committed by Martin Blazik
parent e3920af719
commit 85eb30eb96
2 changed files with 13 additions and 7 deletions

6
bashrc
View File

@@ -10,11 +10,9 @@ if [[ -z $LC_ALL ]]; then
export LC_ALL=en_US.UTF-8
fi
for rc_file in $WORKSPACE/rc/*.sh; do
source $rc_file
done
source "$LWS/functions.sh"
source_directory_sh "$LWS/rc"
append_path "$LWS/bin"
append_path "$LWS/opt/bin"
set_uniq_path

View File

@@ -1,5 +1,7 @@
# Linux Workspace Functions
readonly time_ms='date +%s%3N'
function xlog() {
if true_false "$LWS_DEBUG"; then
echo "$@"
@@ -84,10 +86,17 @@ function can_run() {
function source_directory() {
local mask="$1"
xlog "LOAD DIR $mask"
for file in $mask; do
if [[ -e "$file" ]]; then
xlog "LOAD $file"
source "$file"
if (( $LWS_DEBUG )); then
start=$($time_ms)
source "$file"
stop=$($time_ms)
echo "LOAD FILE $file $((stop - start)) ms"
else
source "$file"
fi
fi
done
}
@@ -115,4 +124,3 @@ function true_false() {
# [[ "${1,,}" =~ ^(1|true|yes)$ ]]
[[ "${1@L}" =~ ^(1|true|yes)$ ]]
}