Measure loading time of scripts
This commit is contained in:
@@ -1,118 +0,0 @@
|
||||
# Linux Workspace Functions
|
||||
|
||||
function xlog() {
|
||||
if true_false "$LWS_DEBUG"; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function jql() {
|
||||
jq -C . "$@" | less -r
|
||||
}
|
||||
|
||||
function ffile() {
|
||||
local filename="$1"
|
||||
shift
|
||||
file $(type -p "$filename") $@
|
||||
}
|
||||
|
||||
# print time in seconds with nanoseconds precission
|
||||
function utime() {
|
||||
date '+%s.%N'
|
||||
}
|
||||
|
||||
function sqltime() {
|
||||
date '+%Y-%m-%d %H:%M:%S'
|
||||
}
|
||||
|
||||
function lines() {
|
||||
tr ":" "\n"
|
||||
}
|
||||
|
||||
function path() {
|
||||
echo "$PATH" | lines
|
||||
}
|
||||
|
||||
function in_path() {
|
||||
[[ "$PATH" =~ (^|:)"${1}"(:|$) ]]
|
||||
}
|
||||
|
||||
function append_path() {
|
||||
if ! in_path "$1"; then
|
||||
PATH="$PATH:$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function append_path_try() {
|
||||
if [[ -e "$1" ]]; then
|
||||
append_path "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function prepend_path() {
|
||||
if ! in_path "$1"; then
|
||||
PATH="$1:$PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
function prepend_path_try() {
|
||||
if [[ -e "$1" ]]; then
|
||||
prepend_path "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_path() {
|
||||
PATH=$(path | grep -v "$1" | tr "\n" ":")
|
||||
}
|
||||
|
||||
function uniq_path() {
|
||||
echo "$PATH" | tr ":" "\n" | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g'
|
||||
}
|
||||
|
||||
function set_uniq_path() {
|
||||
PATH="$(uniq_path)"
|
||||
}
|
||||
|
||||
function is_alias() {
|
||||
alias "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
function can_run() {
|
||||
local application="$1"
|
||||
command -v "$application" > /dev/null
|
||||
}
|
||||
|
||||
function source_directory() {
|
||||
local mask="$1"
|
||||
for file in $mask; do
|
||||
if [[ -e "$file" ]]; then
|
||||
xlog "LOAD $file"
|
||||
source "$file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function source_directory_sh() {
|
||||
source_directory "$1/*.sh"
|
||||
}
|
||||
|
||||
# use: dump_args "$@"
|
||||
function dump_args() {
|
||||
for i in $*; do
|
||||
echo $i
|
||||
done
|
||||
}
|
||||
|
||||
function source_try() {
|
||||
local script="$1"
|
||||
if [[ -e "$script" ]]; then
|
||||
source "$script"
|
||||
fi
|
||||
}
|
||||
|
||||
function true_false() {
|
||||
# lower case and compare
|
||||
# [[ "${1,,}" =~ ^(1|true|yes)$ ]]
|
||||
[[ "${1@L}" =~ ^(1|true|yes)$ ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user