#! /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 '\
    $1 == "Specification:" { p = 1; printf "%s ...\n", FILENAME; print} \
    $1 != "Specification:" { if (p) { if (substr($0,0,1) != " ") p = 0; \
				      else print; }}\
    $1 == "Basic" && $2 == "bulk_get" { thruput = 1; rr = 0; \
					conndisc = 0; def = 0; } \
    $1 == "Basic" && $2 == "rr" { thruput = 0; rr = 1; \
				  conndisc = 0; def = 0; } \
    $1 == "Basic" && $2 == "rpc" { thruput = 0; rr = 1; \
				   conndisc = 0; def = 0; } \
    $1 == "Basic" && $2 == "conn_disc" { thruput = 0; rr = 0; \
					 conndisc = 1; def = 0; } \
    $1 == "Basic" && $2 != "bulk_get" && $2 != "rr" && $2 != "rpc" && \
		     $2 != "conn_disc" && $2 != "bulk_get" \
		{ thruput = 0; rr = 0; conndisc = 0; def = 1; } \

    $6 == "iterations" { it = $7 }

    $1 == "elapsed" \
        { et = $2; min = $3; max = $4; sdev = $5; \
            if (rr) { \
                printf "Two-way delay: %.1f ms\n", et/it; \
                printf "\t(from %.1f to %.1f - standard deviation %.1f\n", \
                       min/it, max/it, sdev/it; \
		printf "\n\n"; \
            } \
            if (conndisc) { \
                printf "Connect plus disconnect: %.1f ms\n", et/it;
                printf "\t(from %.1f to %.1f - standard deviation %.1f\n", \
                       min/it, max/it, sdev/it; \
		printf "\n\n"; \
            } \
            if (def) { \
                printf "Elapsed time: %.1f ms\n", et/it;
                printf "\t(from %.1f to %.1f - standard deviation %.1f\n", \
                       min/it, max/it, sdev/it; \
		printf "\n\n"; \
            } \
        } \

    $1 == "datarcvd" \
        { amount = $2; \
            if (thruput) { \
                printf "Throughput: %.2f kbytes/s\n", amount/et; \
                printf "\t(from %.2f to %.2f - normalized std dev %.1f%%\n", \
                       amount/max, amount/min, 100*sdev/et; \
		printf "\n\n"; \
            } \
        } \
' $*
