#!/bin/bash

echo Upstream Peaks
for i in mem.upstream-single.*; do
    echo $i;
    PEAK=$(ms_print $i|grep peak|cut -d '[' -f 2|cut -d ' ' -f 1)
    PEAKLINE=$(echo $(ms_print $i|egrep "^ *$PEAK "))
    echo PEAK=$PEAKLINE
    BYTES=$(echo $PEAKLINE|cut -d ' ' -f 4|tr -d ,)
    N=$(echo $i|cut -d . -f 4)
    REAL=$[$BYTES-(4*$N)]
    echo "$N elements: $REAL bytes"
done

echo Persistent Peaks
for j in single few many; do
  for i in mem.persistent-$j.*; do
    echo $i;
    PEAK=$(ms_print $i|grep peak|cut -d '[' -f 2|cut -d ' ' -f 1)
    PEAKLINE=$(echo $(ms_print $i|egrep "^ *$PEAK "))
    echo PEAK=$PEAKLINE
    BYTES=$(echo $PEAKLINE|cut -d ' ' -f 4|tr -d ,)
    N=$(echo $i|cut -d . -f 4)
    REAL=$[$BYTES-(4*$N)]
    echo "$N elements: $REAL bytes"
  done
done
