aboutsummaryrefslogtreecommitdiff
path: root/cbt
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-04-26 10:57:09 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2016-04-28 13:33:20 -0400
commit99f624011b3ae0e6088ffcb86dc414e3750ad5c9 (patch)
treeb2c82ef9e6ffb63591870251ecc591d2ec62036b /cbt
parent4f4a5ce29d240e700137e16fdb9156417ae63be1 (diff)
downloadcbt-99f624011b3ae0e6088ffcb86dc414e3750ad5c9.tar.gz
cbt-99f624011b3ae0e6088ffcb86dc414e3750ad5c9.tar.bz2
cbt-99f624011b3ae0e6088ffcb86dc414e3750ad5c9.zip
compute logged times during startup as delta from beginning
Diffstat (limited to 'cbt')
-rwxr-xr-xcbt17
1 files changed, 15 insertions, 2 deletions
diff --git a/cbt b/cbt
index 867276a..a893dff 100755
--- a/cbt
+++ b/cbt
@@ -8,6 +8,19 @@
# - reduction of dependencies
# - performance improvements
+start_seconds=$(gdate +"%s")
+start_nanos=1$(gdate +"%N")
+
+time_taken() {
+ i=$(( $(gdate +"%s") - start_seconds ))
+ n=$(( $(( 1$(gdate +"%N") - start_nanos )) / 1000000 ))
+ if [[ ( "$n" < 0 ) ]]; then
+ i=$(( i-1 ))
+ n=$(( n+1000 ))
+ fi
+ echo "$i.$n"
+}
+
# utility function to log message to stderr with stating the time
log () {
msg=$1
@@ -23,8 +36,8 @@ log () {
which gdate 2>&1 > /dev/null
gdate_installed=$?
if [ $gdate_installed -eq 0 ]; then
- i=`gdate +"%S.%N"`
- echo "[$i] $msg" 1>&2
+ delta=$(time_taken)
+ echo "[$delta] $msg" 1>&2
fi
fi
}