Measure loading time of scripts
This commit is contained in:
6
bashrc
6
bashrc
@@ -10,11 +10,9 @@ if [[ -z $LC_ALL ]]; then
|
|||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for rc_file in $WORKSPACE/rc/*.sh; do
|
source "$LWS/functions.sh"
|
||||||
source $rc_file
|
source_directory_sh "$LWS/rc"
|
||||||
done
|
|
||||||
|
|
||||||
append_path "$LWS/bin"
|
append_path "$LWS/bin"
|
||||||
append_path "$LWS/opt/bin"
|
append_path "$LWS/opt/bin"
|
||||||
set_uniq_path
|
set_uniq_path
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# Linux Workspace Functions
|
# Linux Workspace Functions
|
||||||
|
|
||||||
|
readonly time_ms='date +%s%3N'
|
||||||
|
|
||||||
function xlog() {
|
function xlog() {
|
||||||
if true_false "$LWS_DEBUG"; then
|
if true_false "$LWS_DEBUG"; then
|
||||||
echo "$@"
|
echo "$@"
|
||||||
@@ -84,10 +86,17 @@ function can_run() {
|
|||||||
|
|
||||||
function source_directory() {
|
function source_directory() {
|
||||||
local mask="$1"
|
local mask="$1"
|
||||||
|
xlog "LOAD DIR $mask"
|
||||||
for file in $mask; do
|
for file in $mask; do
|
||||||
if [[ -e "$file" ]]; then
|
if [[ -e "$file" ]]; then
|
||||||
xlog "LOAD $file"
|
if (( $LWS_DEBUG )); then
|
||||||
source "$file"
|
start=$($time_ms)
|
||||||
|
source "$file"
|
||||||
|
stop=$($time_ms)
|
||||||
|
echo "LOAD FILE $file $((stop - start)) ms"
|
||||||
|
else
|
||||||
|
source "$file"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -115,4 +124,3 @@ function true_false() {
|
|||||||
# [[ "${1,,}" =~ ^(1|true|yes)$ ]]
|
# [[ "${1,,}" =~ ^(1|true|yes)$ ]]
|
||||||
[[ "${1@L}" =~ ^(1|true|yes)$ ]]
|
[[ "${1@L}" =~ ^(1|true|yes)$ ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user