-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtime-twice.pl
executable file
·49 lines (43 loc) · 1.39 KB
/
time-twice.pl
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
#!/pro/bin/perl
use 5.18.2;
use warnings;
$| = 1;
binmode STDOUT, ":encoding(utf-8)";
use Getopt::Long qw(:config bundling passthrough);
GetOptions (
"s|silent!" => \my $opt_s,
) or die "usage: $0 [--silent] [options to time.pl]\n";
my (@v, %t, %seen);
foreach my $i (1, 2) {
print "\r";
open my $th, "-|", "time.pl", @ARGV;
binmode $th, ":encoding(utf-8)";
while (<$th>) {
if (m/^([^ ]+[ ]+[^ ]+)[ ]+(?:\**[ ]+)?[0-9]/) {
print $seen{$1}++ || $opt_s ? "." : $_;
next;
}
# print;
if (m/^(?:This is|Welcome to)\s.*\s(v\d+[-.\w]+?)\.?$/) {
$v[0] //= "Rakudo $1";
next;
}
if (m/^Implementing\s.*(v\d\S+?)\.?$/) {
$v[1] //= " ($1)";
next;
}
if (m/^Built on (\w+)\s+version\s+(\S+?)\.?$/) {
$v[2] //= " on $1 $2";
next;
}
my ($s, $t) = m/^(.+?)\s+([0-9][.0-9]+)$/ or next;
push @{$t{$s =~ s/(?:\s+|\xa0|\x{00a0})+/ /gr}}, $t;
}
}
say "";
say join "" => grep { length } @v;
foreach my $t (sort { $t{$a}[0] <=> $t{$b}[0] } keys %t) {
my @t = sort { $a <=> $b } @{$t{$t}};
printf "%-18s %s\n", $t, join " - " => map { sprintf "%6.3f", $_ } @t[0,-1];
}
say "https://tux.nl/Talks/CSV6/speed4-20.html / https://tux.nl/Talks/CSV6/speed4.html https://tux.nl/Talks/CSV6/speed.log";