Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ci
Path: blob/main/scripts/misc/compare_time.pl
1130 views
1
#!/usr/bin/env perl
2
3
use warnings;
4
use strict;
5
6
my $threshold = 5;
7
8
sub count {
9
my $f = shift;
10
my %data;
11
while(<$f>) {
12
next unless /\-\>/;
13
if (/\[([0-9.]+)s\]/) {
14
my $n = (split / /)[0];
15
my $t = $1;
16
$data{$n} = $t;
17
}
18
}
19
%data;
20
}
21
22
open(my $f1, "<$ARGV[0]") or die;
23
open(my $f2, "<$ARGV[1]") or die;
24
25
my %data1 = count($f1);
26
my %data2 = count($f2);
27
my @result;
28
29
while (my ($n, $t1) = each %data1) {
30
next if not exists $data2{$n};
31
my $t2 = $data2{$n};
32
my $d = $t2 - $t1;
33
if ($d > $threshold) {
34
push @result, [$d, $n, $t1, $t2];
35
}
36
}
37
38
foreach my $i (sort { $b->[0] <=> $a->[0] } @result) {
39
my ($d, $n, $t1, $t2) = splice @$i;
40
print "$n :\n";
41
print " $t1 <-> $t2\n"
42
}
43