Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / performance-tests / RTEvent / Colocated_Roundtrip / compare_histo.pl
blob8cfae24888db700a1b95521d590c282777b58b6e
1 #!/usr/bin/env perl -w
4 use English;
6 sub load_file {
7 local $filename = shift;
8 local %R = ();
10 open (XF, $filename)
11 || die "Cannot open $filename\n";
12 while (<XF>) {
13 chomp;
14 local @f = split(/\s+/, $_);
15 $R{$f[0]} = $f[1];
17 close(XF);
19 return %R;
22 sub interpolate {
23 local %T = @_;
24 local %R = ();
26 local $last_i;
27 foreach my $i (sort keys %T) {
28 if (!defined $last_i) {
29 $last_i = $i;
30 $R{$i} = $T{$i};
31 next;
33 local $si = $last_i + 1;
34 while ($si < $i) {
35 $R{$si} = $T{$last_i} + ($si - $last_i) * ($T{$i} - $T{$last_i}) / ($i - $last_i);
36 $si++;
38 $last_i = $i;
39 $R{$i} = $T{$i};
41 return %R;
44 sub range {
45 local @values = @_;
46 local ($min_i, $max_i);
47 foreach my $i (@values) {
48 if (!defined $min_i
49 || $i < $min_i) {
50 $min_i = $i;
52 if (!defined $max_i
53 || $i > $max_i) {
54 $max_i = $i;
57 return ($min_i, $max_i);
60 local %BX = load_file($ARGV[0]);
61 print STDERR "X loaded\n";
62 local %BY = load_file($ARGV[1]);
63 print STDERR "Y loaded\n";
65 local %X = %BX; interpolate (%BX);
66 local %Y = %BY; interpolate (%BY);
68 local ($min_i, $max_i) = range(keys %X);
69 local ($min_j, $max_j) = range(keys %Y);
71 print STDERR "RANGE[X] = $min_i, $max_i\n";
72 print STDERR "RANGE[Y] = $min_j, $max_j\n";
74 local $total = 0;
75 foreach my $i (($min_i - $max_j)..($max_i - $min_j)) {
76 local $z = 0;
77 foreach my $j (-$max_j..-$min_j) {
78 local $f = 0;
79 local $g = 0;
80 if (defined $X{$i - $j}) {
81 $f = $X{$i - $j};
83 if (defined $Y{-$j}) {
84 $g = $Y{-$j};
86 $z += $f * $g;
88 print $i, " ", $z, "\n";
89 $total += $z;
92 print STDERR "TOTAL = $total\n";