-
Notifications
You must be signed in to change notification settings - Fork 88
/
Sort.pm
109 lines (81 loc) · 2.63 KB
/
Sort.pm
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright 2004-2006, Paul Johnson (pjcj@cpan.org)
# This software is free. It is licensed under the same terms as Perl itself.
# The latest version of this software should be available from my homepage:
# http://www.pjcj.net
package Devel::Cover::Report::Sort;
use strict;
use warnings;
our $VERSION = "0.59";
use Devel::Cover::DB 0.59;
sub print_sort
{
my ($db, $options) = @_;
my %runs;
my @collected = grep $_ ne "time", @{$options->{coverage}};
# use Data::Dumper; print Dumper [$db->runs];
for my $r (sort {$a->{start} <=> $b->{start}} $db->runs)
{
print "Run: ", $r->run, "\n";
print "Perl version: ", $r->perl, "\n";
print "OS: ", $r->OS, "\n";
print "Start: ", scalar gmtime $r->start / 1e6, "\n";
print "Finish: ", scalar gmtime $r->finish / 1e6, "\n";
# use Data::Dumper; print Dumper $r;
@{$runs{$r->run}}{"vec", "size"} = ("", 0);
my $run = $runs{$r->run};
# use Data::Dumper; print Dumper $run;
my $vec = $r->vec;
for my $file (@{$options->{file}})
{
# print "$file\n";
for my $criterion (@collected)
{
my ($v, $sz) = @{$vec->{$file}{$criterion}}{"vec", "size"};
$sz |= 0;
printf "$file:%10s %5d: ", $criterion, $sz;
unless($sz)
{
print "\n";
next;
}
for (0 .. $sz - 1)
{
print vec $v, $_, 1;
vec($run->{vec}, $run->{size}++, 1) = vec $v, $_, 1;
}
print "\n";
}
}
$run->{count} += vec $run->{vec}, $_, 1 for 0 .. $run->{size} - 1;
print "Vec: ";
print vec $run->{vec}, $_, 1 for 0 .. $run->{size} - 1;
print "\n";
print "Count: $run->{count} / $run->{size}\n\n";
}
}
sub report
{
my ($pkg, $db, $options) = @_;
print_sort($db, $options);
}
1
__END__
=head1 NAME
Devel::Cover::Report::Sort - Report on runs in an optimal order
=head1 SYNOPSIS
cover -report sort
=head1 DESCRIPTION
This module reports coverage runs in an optimal order.
It is designed to be called from the C<cover> program.
=head1 SEE ALSO
Devel::Cover
=head1 BUGS
Huh?
=head1 VERSION
Version 0.59 - 23rd August 2006
=head1 LICENCE
Copyright 2004-2006, Paul Johnson (pjcj@cpan.org)
This software is free. It is licensed under the same terms as Perl itself.
The latest version of this software should be available from my homepage:
http://www.pjcj.net
=cut