123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- # Extract the bandwith information.
- # Usage: getbw file file....
- #
- # Hacked into existence by Larry McVoy (lm@sun.com now lm@sgi.com).
- # Copyright (c) 1994 Larry McVoy. GPLed software.
- # $Id$
- eval 'exec perl -Ssw $0 "$@"'
- if 0;
- #
- # Default is file bandwidth which lists: mem read, file read (both),
- # mmap read (both), bcopy.
- #
- # -mem turns off the file stuff but turns on rd, wr, rdwr, frd, fwr,
- # bcopy, bzero, cp, fcp.
- #
- foreach $file (@ARGV) {
- open(FD, $file);
- &cache;
- open(FD, $file);
- ($f = $file) =~ s|/|-|;
- if ($mem || $all) {
- print "tmp/bwmem.$f\n";
- open(OUT, ">tmp/bwmem.$f");
- } else {
- print "tmp/bwfile.$f\n";
- open(OUT, ">tmp/bwfile.$f");
- }
- print OUT "%X Memory size \n%Y Bandwidth in MB/sec\n";
- while (<FD>) {
- chop;
- if (/^\[lmbench/) {
- @_ = split;
- if ($_[3] eq "SunOS") {
- $_[3] .= "-$_[5]";
- }
- $uname = "@_";
- }
- if (/^\d+.*Mhz/) {
- @_ = split;
- $mhz = $_[0];
- $tmp = &getinfo("$uname", $mhz);
- if ($mem) {
- print OUT "%T Memory bandwidth for $tmp\n";
- } else {
- print OUT "%T Reread bandwidth for $tmp\n";
- }
- }
- if (/MHZ/) {
- @_ = split;
- $mhz = $_[1];
- chop($mhz) if $mhz =~ /]$/;
- $tmp = &getinfo("$uname", $mhz);
- if ($mem) {
- print OUT "%T Memory bandwidth for $tmp\n";
- } else {
- print OUT "%T Reread bandwidth for $tmp\n";
- }
- }
- if ((!$all && !$mem) && /^"read bandwidth/) {
- print OUT "\"File reread\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if ((!$all && !$mem) && /^"read open2close bandwidth/) {
- print OUT "\"File open2close reread\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if ((!$all && !$mem) && /^"Mmap read bandwidth/) {
- print OUT "\"File mmap reread\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if ((!$all && !$mem) && /^"Mmap read open2close bandwidth/) {
- print OUT "\"File mmap open2close reread\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if ($all && /^"libc bcopy aligned/) {
- print OUT "\"libc bcopy aligned\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (/^"libc bcopy unaligned/) {
- print OUT "\"libc bcopy unaligned\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if ($all && /^"unrolled bcopy aligned/) {
- print OUT "\"libc bcopy unaligned\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (($all || $mem) && /^"unrolled bcopy unaligned/) {
- print OUT "\"unrolled bcopy unaligned\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (($all || $mem) && /^"unrolled partial bcopy unaligned/) {
- print OUT "\"unrolled partial bcopy unaligned\n";
- while (<FD>) {
- last if /^\s*$/;
- @_ = split; next unless $_[0] > $cache;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (/^Memory read bandwidth/) {
- print OUT "\"$_\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (($all || $mem) && /^Memory partial read bandwidth/) {
- print OUT "\"$_\n";
- while (<FD>) {
- last if /^\s*$/;
- @_ = split; next unless $_[0] > $cache;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (($all || $mem) && /^Memory partial read.write bandwidth/) {
- print OUT "\"$_\n";
- while (<FD>) {
- last if /^\s*$/;
- @_ = split; next unless $_[0] > $cache;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (($all || $mem) && /^Memory partial write bandwidth/) {
- print OUT "\"$_\n";
- while (<FD>) {
- last if /^\s*$/;
- @_ = split; next unless $_[0] > $cache;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (($all || $mem) && /^Memory write bandwidth/) {
- print OUT "\"$_\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- if (($all || $mem) && /^Memory bzero bandwidth/) {
- print OUT "\"$_\n";
- while (<FD>) {
- last if /^\s*$/;
- print OUT;
- }
- print OUT "\n";
- next;
- }
- }
- }
- # Paw through the data and figure out how big the L1 cache is.
- # We look at the memory read performance and look for cluster breaks
- # at 4, 8, 16, 32, 64, 126, and 256k.
- sub cache
- {
- local($in) = 0;
- local($n, $sum, $avg) = (0,0,0);
- $cache = 0;
- while (<FD>) {
- if (/^Memory partial read bandwidth/) {
- $in = 1;
- next;
- }
- next unless $in;
- @_ = split;
- if ($n == 0) {
- $sum += $_[1];
- $n++;
- next;
- }
- $avg = $sum/$n;
- if ($_[1] < .75*$avg) {
- $cache = $last;
- return;
- }
- $last = $_[0];
- $sum += $_[1];
- $n++;
- }
- }
- # Try and create sensible names from uname -a output
- sub getinfo
- {
- local(@info);
- local($name);
- local($mhz);
- $mhz = $_[1];
- $_ = $_[0];
- @info = split;
- $name = pop(@info);
- chop($name);
- if ($name eq "unknown") {
- $name = pop(@info);
- }
- if ($name eq "mips") {
- $name = "$info[$#info]\@$mhz";
- } elsif ($_[0] =~ /HP-UX/) {
- $name = "$info[7]\@$mhz";
- } elsif ($_[0] =~ /SunOS/) {
- $name = "$info[7]\@$mhz";
- } else {
- $name .= "\@$mhz";
- }
- "$info[3] $name";
- }
|