lib/scripts/timestart.bash
author wenzelm
Thu Dec 01 18:44:47 2005 +0100 (2005-12-01)
changeset 18322 56554bb23eda
parent 18317 bab988e37393
child 18327 1ee4523c831f
permissions -rw-r--r--
cpu time = user + system;
wenzelm@18317
     1
# -*- shell-script -*-
wenzelm@18317
     2
# $Id$
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
#set by configure
wenzelm@18317
    11
AUTO_PERL=perl
wenzelm@18317
    12
wenzelm@18317
    13
function get_times () {
wenzelm@18317
    14
  local TMP="/tmp/get_times$$"
wenzelm@18317
    15
  times > "$TMP"   # No pipe here!
wenzelm@18322
    16
  TIMES_RESULT="$SECONDS $(tail -1 "$TMP" | "$AUTO_PERL" -pe 's,(\d+)m(\d+)\.\d+s +(\d+)m(\d+)\.\d+s, $1 * 60 + $2 + $3 * 60 + $4,e')"
wenzelm@18317
    17
  /bin/rm -f "$TMP"
wenzelm@18317
    18
}
wenzelm@18317
    19
wenzelm@18317
    20
get_times  # sets TIMES_RESULT