1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/usr/bin/env perl
# Look at a bunch of bargraph files and figure out the max amongst them all.
# Usage: getmax file 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;
$graph = 1 if 0;
$exit = 1;
foreach $file (@ARGV) {
$exit = 0 if -f $file;
}
exit $exit if $noop;
$noop = 1 if 0;
$max_X = $max_Y = -1000000000;
$min_X = $min_Y = 1000000000;
foreach $file (@ARGV) {
next if $rmmax;
unless (open(FD, $file)) {
warn "Can't open $file\n";
next;
}
while (<FD>) {
next if /^"/;
next if /^%/;
next if /^\s*$/;
next if m|scripts/lmbench: /dev/tty|;
@_ = split;
$min_X = $_[0] if ($_[0] < $min_X);
$min_Y = $_[1] if ($_[1] < $min_Y);
$max_X = $_[0] if ($_[0] > $max_X);
$max_Y = $_[1] if ($_[1] > $max_Y);
}
close(FD);
}
$half = 0 if 0; # lint
$max_X /= 2 if ($half);
foreach $file (@ARGV) {
unless (open(FD, $file)) {
warn "Can't open $file\n";
next;
}
@lines = <FD>;
open(FD, ">$file") || die "Can't open $file\n";
if ($graph) {
print FD "%fakemin-X $min_X\n";
print FD "%fakemin-Y $min_Y\n";
print FD "%fakemax-X $max_X\n";
print FD "%fakemax-Y $max_Y\n";
foreach $_ (@lines) {
next if /^%fakem/;
print FD;
}
warn "Max X is $max_X\n" if $v;
warn "Max Y is $max_Y\n" if $v;
} elsif ($rmmax) {
foreach $_ (@lines) {
next if /^%fakem/;
print FD;
}
} else {
print FD @lines;
print FD "%fakemax $max_X\n";
warn "Max X is $max_X\n" if $v;
}
close(FD);
}
exit $exit;
|