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
|
||||
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
|
||||
|
||||
|
||||
@@ -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)$ ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user