File: cmplog.pl

package info (click to toggle)
allegro4.2 2:4.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,436 kB
  • ctags: 14,714
  • sloc: ansic: 126,425; asm: 17,011; cpp: 3,846; sh: 2,120; objc: 925; makefile: 715; python: 216; pascal: 179; perl: 73
file content (42 lines) | stat: -rwxr-xr-x 1,072 bytes parent folder | download | duplicates (12)
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
#! /usr/bin/perl
#
#  Perl script for comparing the output of two test.exe profile logs,
#  converting the time values into a percentage difference.
#
#  Usage: cmplog profile1.log profile2.log


if (not (($f1 = shift) && ($f2 = shift))) {
   print "Usage: cmplog file1.log file2.log\n";
   exit
}

open A, $f1 or die "Can't open first input file ($f1)\n";
open B, $f2 or die "Can't open second input file ($f2)\n";

print "Comparing test profile logs $f1 and $f2\n";

while ($l1 = <A> and $l2 = <B>) {
   if ($l1 =~ /Hardware acceleration/) {
      $l1 = <A>;
      do { $l1 = <A>; } until ($l1 =~ /^\r?$/);
   }

   if ($l2 =~ /Hardware acceleration/) {
      $l2 = <B>;
      do { $l2 = <B>; } until ($l2 =~ /^\r?$/);
   }

   if ($l1 =~ /\s+(.+)\s+- ([0-9]+|N\/A)/) {
      $name = $1;
      $v1 = $2;
      $l2 =~ /- ([0-9]+|N\/A)/;
      $v2 = $1;
      $p = ($v1 == 0) || ($v2 == 0) ? "N/A" : int($v2*100/$v1) . "%";
      $name .= " " x (32 - length($name));
      print "\t$name = $p\n";
   }
   elsif ($l1 =~ /^\r?(.*):\r?$/) {
      print "\n\n$1:\n\n";
   }
}