#!/bin/sh

if [ $# = 0 ]; then
  exit 1
fi

case "$1" in
  *gz) CAT="gunzip -c" ;;
  *Z)  CAT="uncompress -c" ;;
  *)   CAT="cat" ;;
esac

$CAT "$@" | egrep 'Time = |CPU time = |cpu_time' \
       | tr -d , | grep -v total_cpu_time \
    | awk '{if ($1 == "Time") t = $3; \
	    if ($1 == "CPU" && $4 > cpu) cpu = $4; \
	    if ($1 == "count") {t = $6; cpu = $12;}; \
	    if ($1 != "Time") print t, cpu;}' \
    | plot_data -q -x 'time' -y CPU -C red -h "Data from $*"
