lib/scripts/timestart.bash
author wenzelm
Thu May 20 20:20:52 2010 +0200 (2010-05-20)
changeset 37012 106c56e916f8
parent 31310 b5365a9db718
child 58639 1df53737c59b
permissions -rw-r--r--
enable shell script editor mode;
     1 # -*- shell-script -*- :mode=shellscript:
     2 #
     3 # Author: Makarius
     4 #
     5 # timestart - setup bash environment for timing.
     6 #
     7 
     8 TIMES_RESULT=""
     9 
    10 function get_times () {
    11   local TMP="/tmp/get_times$$"
    12   times > "$TMP"   # No pipe here!
    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')"
    14   rm -f "$TMP"
    15 }
    16 
    17 get_times  # sets TIMES_RESULT