--- /dev/null
+#\r
+# Copyright (c) 2003\r
+# The President and Fellows of Harvard College.\r
+#\r
+# Redistribution and use in source and binary forms, with or without\r
+# modification, are permitted provided that the following conditions\r
+# are met:\r
+# 1. Redistributions of source code must retain the above copyright\r
+# notice, this list of conditions and the following disclaimer.\r
+# 2. Redistributions in binary form must reproduce the above copyright\r
+# notice, this list of conditions and the following disclaimer in the\r
+# documentation and/or other materials provided with the distribution.\r
+# 3. Neither the name of the University nor the names of its contributors\r
+# may be used to endorse or promote products derived from this software\r
+# without specific prior written permission.\r
+#\r
+# THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND\r
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+# ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE\r
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+# SUCH DAMAGE.\r
+#\r
+# $Id: counts.pl,v 1.9 2003/07/28 14:27:16 ellard Exp $\r
+\r
+package counts;\r
+\r
+@OpList = ();\r
+%KeysSeen = ();\r
+\r
+%OpCounts = ();\r
+\r
+sub init {\r
+ my (@oplist) = @_;\r
+\r
+ @OpList = @oplist;\r
+}\r
+\r
+sub printTitle {\r
+ my ($out) = @_;\r
+\r
+ my $str = "#C time client fh euid egid";\r
+\r
+ foreach my $op ( @OpList ) {\r
+ $str .= " $op";\r
+ }\r
+ $str .= "\n";\r
+\r
+ print $out $str;\r
+} \r
+\r
+sub printOps {\r
+ my ($start_time, $out) = @_;\r
+ my ($k, $str, $op, $nk);\r
+\r
+ my @allkeys = sort keys %KeysSeen;\r
+\r
+ foreach $k ( @allkeys ) {\r
+ my $tot = "$k,TOTAL";\r
+\r
+ if ($main::OMIT_ZEROS &&\r
+ (! exists $OpCounts{$tot} || $OpCounts{$tot} == 0)) {\r
+ next;\r
+ }\r
+\r
+ $str = sprintf ("C %s %s", $start_time, &key::key2str ($k));\r
+\r
+ foreach $op ( @OpList ) {\r
+ $nk = "$k,$op";\r
+ if (exists $OpCounts{$nk}) {\r
+ if ($op eq 'readM' || $op eq 'writeM') {\r
+ $str .= sprintf (" %.3f",\r
+ $OpCounts{$nk} / (1024 * 1024));\r
+ }\r
+ else {\r
+ $str .= " $OpCounts{$nk}"\r
+ }\r
+ }\r
+ else {\r
+ $str .= " 0";\r
+ }\r
+ }\r
+ $str .= "\n";\r
+ print $out $str;\r
+ }\r
+}\r
+\r
+sub resetOpCounts {\r
+\r
+ # Clear the counts on everything we've seen.\r
+\r
+ foreach my $op ( keys %OpCounts ) {\r
+ $OpCounts{$op} = 0;\r
+ }\r
+}\r
+\r
+1;\r
+\r