#!/bin/sh
# --------------------------------------------------------------------------
# Copyright 1992-1994 by Forschungszentrum Informatik (FZI)
# All rights reserved.
#
# You can use and distribute this software under the terms of the license
# you should have received along with this software; either version 1.1 of
# the license, or (at your option) any later version.
# For a copy of the license or for additional information about this software,
# write to Xcc Software, Durlacher Allee 53, D-76131 Karlsruhe, Germany;
# Email: obst@xcc-ka.de.
# --------------------------------------------------------------------------
# 'obst-csz - 27:02:91 - Dietmar Theobald'
#
# obst-csz [-o] [-l <level>] [<container [<offset]]
#
# Produce size statistics from dump.
#
 self='obst-csz'
usage='[-o] [-l <level>] [<container [<offset]]'

[ -n "$OBSTdir" ] || { OBSTdir="`cd \`dirname $0\`;pwd`/"; export OBSTdir; }

for arg
do
   case "$arg" in
      -l|-o) ;;
         -*) echo >&2 "*** usage: $self $usage"
             exit 1 ;;
   esac
done

if [ -z "$OBSTCONTAINER" -a -z "$SOSCONTAINER" ] ; then
  echo >&2 "*** $self: environment variable OBSTCONTAINER not defined"
  exit 1
fi

${OBSTdir}dmp $*\
   | sed -e 's|^<\([0-9]*\)/.*:\[\([^(]*\)(\([0-9]*\)).*|\1 \2 \3|'\
   | awk 'BEGIN {FS=" "}
		{a[$1 " of " $2]  += $3
		 a[$1 " of  all"] += $3
		 b[$1 " of " $2]  += 1
		 b[$1 " of  all"] += 1
		}
	  END   {for (i in a) print "size/count in " i " = " a[i] " / " b[i]
		}'\
   | sort
