summaryrefslogtreecommitdiffstats
path: root/timer
diff options
context:
space:
mode:
Diffstat (limited to 'timer')
-rwxr-xr-xtimer15
1 files changed, 15 insertions, 0 deletions
diff --git a/timer b/timer
index e47bbcb..2436625 100755
--- a/timer
+++ b/timer
@@ -31,6 +31,21 @@ function timer()
fi
}
+function timer_dt()
+{
+ if [[ $# -eq 0 ]]; then
+ echo $(date '+%s')
+ else
+ local stime=$1
+ etime=$(date '+%s')
+
+ if [[ -z "$stime" ]]; then stime=$etime; fi
+
+ dt=$((etime - stime))
+ printf '%d' $dt
+ fi
+}
+
# If invoked directly run test code.
if [[ $(basename $0 .sh) == 'timer' ]]; then
t=$(timer)