#! /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 == "Basic" && $2 == "bulk_get" { thruput = 1; rr = 0; conndisc = 0; } \
    $1 == "Basic" && $2 == "rr" { thruput = 0; rr = 1; conndisc = 0; } \
    $1 == "Basic" && $2 == "conn_disc" { thruput = 0; rr = 0; conndisc = 1; } \

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

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

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