52875ae8737694d9d74d89be9f4dcd5de234e60b
[packages/containers.git] / benchmarks / bench-cmp.pl
1 #!/usr/bin/env perl
2 use warnings;
3 use strict;
4
5 @ARGV >= 2 or die "Usage: bench-cmp.pl csv_file_1 csv_file_2";
6 open (my $f1, "<", $ARGV[0]) or die "Cannot open file $ARGV[0]";
7 open (my $f2, "<", $ARGV[1]) or die "Cannot open file $ARGV[1]";
8
9 my $l1 = <$f1>;
10 my $l2 = <$f2>;
11 $l1 eq $l2 or die "CSV files do not correspond -- $l1 and $l2";
12
13 while (defined($l1 = <$f1>)) {
14 $l2 = <$f2>;
15
16 my @parts1 = split /,/, $l1;
17 my @parts2 = split /,/, $l2;
18
19 $parts1[0] eq $parts2[0] or die "CSV files do not correspond -- $parts1[0] and $parts2[0]";
20 printf "%s;%+7.2f%%;%.2e\n", $parts1[0], 100 * $parts2[1] / $parts1[1] - 100, $parts1[1];
21 }
22
23 close $f2;
24 close $f1;