<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/afs/athena/contrib/perl/perl5

sub sample {
    local($what,$x,$count) = @_;

    if (!$count) { $count = 1; }

    push(@{$samples{$what}}, ($x)x$count);
    $sum{$what} += $x*$count;
    $sumsquare{$what} += $x*$x*$count;
    $count{$what} += $count;
}

sub mean { $sum{$_[0]}/$count{$_[0]}; }

sub stddev { sqrt(($sumsquare{$_[0]}/$count{$_[0]})-
		  ($sum{$_[0]}/$count{$_[0]})*($sum{$_[0]}/$count{$_[0]})); }

sub stats {
    local($what) = @_;

    if (!$count{$what}) {
	print "no stats for $what\n\n";
    } else {
	print " count $what = ",$count{$what},"\n";
	print "  mean $what = ",&amp;mean($what),"\n";
	@tmp = (sort {$a&lt;=&gt;$b} @{$samples{$what}});
	print "median $what = ",$tmp[$#tmp/2],"\n";
	print "stddev $what = ",&amp;stddev($what),"\n";
	@h = (); $hh = "";
	grep($_&lt;7900 &amp;&amp; ($h[$_/100]+=1/2),@tmp);
	grep(($n=$_,grep($hh.=($_&lt;=$n)?" ":"X",@h),$hh.="\n"),reverse(0..20));
	print " histo $what = \n$hh";
#	print "samples = ",join(",",@tmp),"\n";
	print "\n";
    }
}

while(&lt;&gt;) {
    chop;

    /^.* - - \[(\d+)\/Oct\/1995:(\d+):(\d+):(\d+)/ || next;

    ### offset in seconds from midnight, 1 october 1995
    $time = ($1-1)*86400+$2*3600+$3*60+$4;
    $msg = $';

    $firsttime = $time if !$firsttime;
    $lasttime = $time;

    if (/pks-extract-key/i) {
	split;
	$size = $_[$#_];
	if (/op=index/i) {
	    if ($size eq "-") {
		$indexfailed++;
	    } else {
		&amp;sample("index",$size);
	    }
	} elsif (/op=vindex/i) {
	    if ($size eq "-") {
		$vindexfailed++;
	    } else {
		&amp;sample("vindex",$size);
	    }
	} elsif (/op=get/i) {
	    if (/search=0x/i) {
		if ($size eq "-") {
		    $getidfailed++;
		} else {
		    &amp;sample("getid",$size);
		}
	    } else {
		if ($size eq "-") {
		    $getnamefailed++;
		} else {
		    &amp;sample("getname",$size);
		}
	    }
	}
    } elsif (/pks-add-key/i) {
	if ($size !~ /-/) {
	    &amp;sample("add", $size);
	}
    }
}

print " count index failed = ",$indexfailed,"\n";
&amp;stats("index");
print "count vindex failed = ",$vindexfailed,"\n";
&amp;stats("vindex");
print "count getid failed = ",$getidfailed,"\n";
&amp;stats("getid");
print "count getname failed = ",$getnamefailed,"\n";
&amp;stats("getname");
&amp;stats("add");

print "total time is ",$lasttime-$firsttime," seconds (",
    ($lasttime-$firsttime)/86400," days).\n";
</pre></body></html>