#! /bin/sh
# The SPIMS software is covered by a license. The use of the software
# represents acceptance of the terms and conditions in the license.
# ******************************************************************
# Copyright (c) 1989, Swedish Institute of Computer Science
awk '
BEGIN 		{ i = 0; } 
$1 == "ERROR" 	{ print }
$1 == "pagerecl"	{ print }
$1 == "pageio" 		{ print }
$1 == "swaps" 		{ print }
$1 == "Constant" && $2 == "value" { ms = $3;} 
$1 == "cputime"		{ cpu = $2 }
$1 == "elapsed" 	{
	et = $2; 
	if (length($3) != 0) min = $3; else min = 0; 
	if (length($4) != 0) max = $4; else max = 0; 
	if (length($5) != 0) std = $5; else std = 0; 
}
$1 == "datarcvd" || $1 == "datasent" {
	if (et != 0) {
		printf "%d\t%f ", ms, $2/et;
		printf "\tCPU usage %.2f%%", 100*cpu/et;
		if (min != 0 && max != 0) { 
			printf "\t(min %.2f, max %.2f, std dev. %.3f)\n", \
				$2/max, $2/min, std/et; 
		} else {
			printf "\n";
		} 
	}
	i++
} 
' $*
