lib/scripts/timestart.bash
author wenzelm
Wed Nov 01 17:29:14 2017 +0100 (20 months ago)
changeset 66980 8947cf58cb86
parent 58639 1df53737c59b
permissions -rw-r--r--
tuned output;
wenzelm@31310
     1
# -*- shell-script -*- :mode=shellscript:
wenzelm@29145
     2
#
wenzelm@18317
     3
# Author: Makarius
wenzelm@18317
     4
#
wenzelm@18317
     5
# timestart - setup bash environment for timing.
wenzelm@18317
     6
#
wenzelm@18317
     7
wenzelm@18317
     8
TIMES_RESULT=""
wenzelm@18317
     9
wenzelm@18317
    10
function get_times () {
wenzelm@58639
    11
  local TMP="${TMPDIR:-/tmp}/get_times$$"
wenzelm@18317
    12
  times > "$TMP"   # No pipe here!
wenzelm@26576
    13
  TIMES_RESULT="$SECONDS $(echo $(cat "$TMP") | perl -pe 's,\d+m\d+\.\d+s \d+m\d+\.\d+s (\d+)m(\d+)\.\d+s +(\d+)m(\d+)\.\d+s, $1 * 60 + $2 + $3 * 60 + $4,e')"
wenzelm@18327
    14
  rm -f "$TMP"
wenzelm@18317
    15
}
wenzelm@18317
    16
wenzelm@18317
    17
get_times  # sets TIMES_RESULT