blib/lib/App/loggrep.pm

filter: Statementstmt 82.4% 193 / 234 Branchbran 66.9% 87 / 130 Conditioncond 68.4% 50 / 73 MC/DCmcdc 43.9% 18 / 41 Subroutinesub 100% 16 / 16 Podpod 100% 3 / 3 totaltotal 73.8% 367 / 497 CC 104 SCAR 38.0
CC
104
Cov
76%
init
85.1
grep
37.9
_get_start
31.7
CRAP 44.5
↑ Summary
1 package App::loggrep;
2 2 $App::loggrep::VERSION = '0.002';
3 # ABSTRACT: quickly find relevant lines in a log searching by date
4  
5 2 ▶$App::loggrep::VERSION //= 'dev';
Condition50%1/2
$VERSION //= "dev"
l!l
20
MC/DC0%0/1
$VERSION //= "dev"
$VERSION
Truth table50%1/2
A
A= $VERSION
Aresult
11
00
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Tie::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Date::Parse qw(str2time);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 12 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
14 12 my ( $class, $log, $opt ) = @_;
15 12 bless { filename => $log, options => $opt }, $class;
16 }
17  
18  
19 12 ▶sub init {
Subroutine init: called CC=40 SCAR=44.4
Pod documented
20 12 my $self = shift;
21 12 my @errors;
22 12 my $filename = $self->{filename};
23 12 my @lines;
24 12 my $opt = delete $self->{options};
25 {
26 12 ▶ unless ( defined $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $filename) 0 12 12
27 0 push @errors, 'no log file provided';
28 0 last;
29 }
30 12 ▶ unless ( -e $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $filename) 0 12 12
31 0 push @errors, "file $filename does not exist";
32 0 last;
33 }
34 12 ▶ if ( -d $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $filename) 0 12 12
35 0 push @errors, "$filename is a directory";
36 0 last;
37 }
38 12 ▶ unless ( -r $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-r $filename) 0 12 12
39 0 push @errors, "cannot read $filename";
40 0 last;
41 }
42 12 ▶ tie @lines, 'Tie::File', $filename or push @errors, $!;
Branch: 1 branch
BranchTrueFalseTotal
tie @lines, "Tie::File", $filename or push @errors, $! 12 0 12
43 12 $self->{lines} = \@lines;
44 }
45 12 $self->{date} = _make_rx( $opt->date, \@errors, 'date' );
46 12 ▶ my @inclusions = @{ $opt->include // [] };
Condition100%2/2
$opt->include // []
l!l
210
MC/DC100%1/1
$opt->include // []
$opt->include
Truth table100%2/2
A
A= $opt->include
Aresult
11
00
47 12 my $insensitive = $opt->case_insensitive;
48 12 $_ = _make_rx( $_, \@errors, 'inclusion', 0, $insensitive ) for @inclusions;
49 push @inclusions, _make_rx( $_, \@errors, 'inclusion', 1, $insensitive )
50 12 ▶ for @{ $opt->include_quoted // [] };
Condition50%1/2
$opt->include_quoted // []
l!l
012
MC/DC0%0/1
$opt->include_quoted // []
$opt->include_quoted
Truth table50%1/2
A
A= $opt->include_quoted
Aresult
11
00
51 0 $self->{include} = [ sort { length($a) <=> length($b) } @inclusions ];
52 12 ▶ my @exclusions = @{ $opt->exclude // [] };
Condition100%2/2
$opt->exclude // []
l!l
210
MC/DC100%1/1
$opt->exclude // []
$opt->exclude
Truth table100%2/2
A
A= $opt->exclude
Aresult
11
00
53 12 $_ = _make_rx( $_, \@errors, 'exclude', 0, $insensitive ) for @exclusions;
54 push @exclusions, _make_rx( $_, \@errors, 'exclude', 1, $insensitive )
55 12 ▶ for @{ $opt->exclude_quoted // [] };
Condition50%1/2
$opt->exclude_quoted // []
l!l
012
MC/DC0%0/1
$opt->exclude_quoted // []
$opt->exclude_quoted
Truth table50%1/2
A
A= $opt->exclude_quoted
Aresult
11
00
56 0 $self->{exclude} = [ sort { length($a) <=> length($b) } @exclusions ];
57 12 ▶ my $start = $opt->start // $opt->moment;
Condition66%2/3
$opt->start // $opt->moment
l!l&&r!l&&!r
804
MC/DC50%1/2
$opt->start // $opt->moment
$opt->start $opt->moment
Truth table66%2/3
A // B
A= $opt->startB= $opt->moment
ABresult
1X1
011
000
58  
59 12 ▶ if ($start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start) 8 4 12
60 8 my $s = str2time $start;
61 8 ▶ push @errors, "cannot parse start time: $start" unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 0 8 8
62 8 $self->{start} = $s;
63 }
64 12 ▶ my $end = $opt->end // $opt->moment;
Condition66%2/3
$opt->end // $opt->moment
l!l&&r!l&&!r
804
MC/DC50%1/2
$opt->end // $opt->moment
$opt->end $opt->moment
Truth table66%2/3
A // B
A= $opt->endB= $opt->moment
ABresult
1X1
011
000
65 12 ▶ if ($end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($end) 8 4 12
66 8 my $s = str2time $end;
67 8 ▶ push @errors, "cannot parse end time: $end" unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 0 8 8
68 8 $self->{end} = $s;
69 }
70 12 ▶ push @errors, 'you are not filtering at all'
Branch: 1 branch
BranchTrueFalseTotal
unless @inclusions or @exclusions or $start or $end 0 12 12
Condition66%6/9
@inclusions or @exclusions or $start or $end
l!l&&r!l&&!r
1200
@inclusions or @exclusions or $start
l!l&&r!l&&!r
480
@inclusions or @exclusions
l!l&&r!l&&!r
228
MC/DC0%0/4
@inclusions or @exclusions or $start or $end
@inclusions @exclusions $start $end
Truth table60%3/5
A or B or C or D
A= @inclusionsB= @exclusionsC= $startD= $end
ABCDresult
1XXX1
01XX1
001X1
00011
00000
71 unless @inclusions || @exclusions || $start || $end;
72  
73 12 ▶ $self->{blank} = $opt->blank || defined $opt->separator;
Condition66%2/3
$opt->blank || defined $opt->separator
l!l&&r!l&&!r
1011
MC/DC50%1/2
$opt->blank || defined $opt->separator
$opt->blank defined $opt->separator
Truth table66%2/3
A || B
A= $opt->blankB= defined $opt->separator
ABresult
1X1
011
000
74 12 $self->{separator} = $opt->separator;
75 12 $self->{warn} = $opt->warn;
76 12 $self->{die} = $opt->die;
77 12 my ( $before, $after ) = ( 0, 0 );
78 12 ▶ if ( $opt->context || $opt->before || $opt->after ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->context or $opt->before or $opt->after) 5 7 12
Condition100%6/6
$opt->context or $opt->before or $opt->after
l!l&&r!l&&!r
417
$opt->context or $opt->before
l!l&&r!l&&!r
228
MC/DC100%3/3
$opt->context or $opt->before or $opt->after
$opt->context $opt->before $opt->after
Truth table100%4/4
A or B or C
A= $opt->contextB= $opt->beforeC= $opt->after
ABCresult
1XX1
01X1
0011
0000
79 5 ▶ $before = $opt->context // 0;
Condition100%2/2
$opt->context // 0
l!l
23
MC/DC100%1/1
$opt->context // 0
$opt->context
Truth table100%2/2
A
A= $opt->context
Aresult
11
00
80 5 ▶ $before = $opt->before if $opt->before && $opt->before > $before;
Branch: 1 branch
BranchTrueFalseTotal
if $opt->before and $opt->before > $before 2 3 5
Condition66%2/3
$opt->before and $opt->before > $before
!ll&&!rl&&r
302
MC/DC50%1/2
$opt->before and $opt->before > $before
$opt->before $opt->before > $before
Truth table66%2/3
A and B
A= $opt->beforeB= $opt->before > $before
ABresult
0X0
100
111
81 5 ▶ $after = $opt->context // 0;
Condition100%2/2
$opt->context // 0
l!l
23
MC/DC100%1/1
$opt->context // 0
$opt->context
Truth table100%2/2
A
A= $opt->context
Aresult
11
00
82 5 ▶ $after = $opt->after if $opt->after && $opt->after > $after;
Branch: 1 branch
BranchTrueFalseTotal
if $opt->after and $opt->after > $after 1 4 5
Condition66%2/3
$opt->after and $opt->after > $after
!ll&&!rl&&r
401
MC/DC50%1/2
$opt->after and $opt->after > $after
$opt->after $opt->after > $after
Truth table66%2/3
A and B
A= $opt->afterB= $opt->after > $after
ABresult
0X0
100
111
83 }
84 12 @$self{qw(before after)} = ( $before, $after );
85  
86 { # code options live in their own namespace
87  
88 12 package __evaled;
89 12 $__evaled::VERSION = '0.002';
90 12 ▶ for my $m ( @{ $opt->module // [] } ) {
Condition50%1/2
$opt->module // []
l!l
012
MC/DC0%0/1
$opt->module // []
$opt->module
Truth table50%1/2
A
A= $opt->module
Aresult
11
00
91 0 ▶ eval "use $_" for @{ $opt->module // [] };
Condition0%0/2
$opt->module // []
l!l
00
MC/DC0%0/1
$opt->module // []
$opt->module
Truth table0%0/2
A
A= $opt->module
Aresult
11
00
92 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
93 0 push @errors, "could not load $m";
94 }
95 }
96 24 ▶ my $evaler = sub {
Subroutine __ANON__: called CC=3 SCAR=19.6
97 24 my ( $orig, $option ) = shift;
98 24 ▶ return unless $orig;
Branch: 1 branch
BranchTrueFalseTotal
unless $orig 24 0 24
99 0 my $majv = int $];
100 0 my $minv = int( 1000 * ( $] - $majv ) );
101 0 my $code =
102 eval "sub { use v$majv.$minv; no strict; no warnings; $orig }";
103 0 ▶ if ( my $e = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 0 0
104 0 $e =~ s/(.*?) at \(eval \d+\).*/$1/s;
105 0 push @errors,
106 sprintf 'bad option: --%s; could not evaluate "%s" as perl: %s',
107 $option,
108 $orig,
109 $e;
110 }
111 0 return $code;
112 12 };
113 12 ▶ $self->{code} = $evaler->( $opt->exec, 'exec' ) // sub { shift };
Subroutine __ANON__: called CC=1 SCAR=0.6
Condition33%1/3
&$evaler($opt->exec, "exec") // sub { shift(); }
l!l&&r!l&&!r
0120
MC/DC0%0/2
&$evaler($opt->exec, "exec") // sub { shift(); }
&$evaler($opt->exec, "exec") sub { shift(); }
Truth table33%1/3
A // B
A= &$evaler($opt->exec, "exec")B= sub { shift(); }
ABresult
1X1
011
000
114 12 $self->{time} = $evaler->( $opt->time, 'time' );
115 }
116  
117 12 return @errors;
118 }
119  
120 # parse a regular expression parameter, registering any errors
121 16 ▶sub _make_rx {
Subroutine _make_rx: called CC=5 SCAR=18.3
122 16 my ( $rx, $errors, $type, $quote, $insensitive ) = @_;
123 16 ▶ unless ($rx) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rx) 0 16 16
124 0 push @$errors, "inadequate $type pattern";
125 0 return;
126 }
127 16 ▶ $rx = quotemeta $rx if $quote;
Branch: 1 branch
BranchTrueFalseTotal
if $quote 0 16 16
128 16 ▶ eval { $rx = $insensitive ? qr/$rx/i : qr/$rx/ };
Branch: 1 branch
BranchTrueFalseTotal
$insensitive ? : 2 14 16
129 16 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 16 16
130 0 push @$errors, "bad $type regex: $rx; error: $@";
131 0 return;
132 }
133 16 return $rx;
134 }
135  
136  
137 12 ▶sub grep {
Subroutine grep: called CC=35 SCAR=36.4
Pod documented
138 12 my $self = shift;
139 my ( $start, $end, $lines, $include, $exclude, $date, $time ) =
140 12 @$self{qw(start end lines include exclude date time)};
141 12 ▶ $time //= sub { str2time $1 if shift =~ $date };
Subroutine __ANON__: called CC=2 SCAR=7.4
Branch: 1 branch
BranchTrueFalseTotal
if (shift()) =~ /$date/ 55 94 149
Condition33%1/3
$time //= sub { str2time($1) if (shift()) =~ /$date/; }
l!l&&r!l&&!r
0120
MC/DC0%0/2
$time //= sub { str2time($1) if (shift()) =~ /$date/; }
$time sub { str2time($1) if (shift()) =~ /$date/; }
Truth table33%1/3
A //= B
A= $timeB= sub { str2time($1) if (shift()) =~ /$date/; }
ABresult
1X1
011
000
142 my ( $blank, $warn, $die, $separator, $before, $after, $code ) =
143 12 @$self{qw(blank warn die separator before after code)};
144 12 ▶ return unless @$lines;
Branch: 1 branch
BranchTrueFalseTotal
unless @$lines 0 12 12
145 12 ▶ my $quiet = !( $warn || $die );
Condition33%1/3
$warn || $die
l!l&&r!l&&!r
0012
MC/DC0%0/2
$warn || $die
$warn $die
Truth table33%1/3
A || B
A= $warnB= $die
ABresult
1X1
011
000
146 12 ▶ $blank ||= defined $separator;
Condition66%2/3
$blank ||= defined $separator
l!l&&r!l&&!r
1011
MC/DC50%1/2
$blank ||= defined $separator
$blank defined $separator
Truth table66%2/3
A ||= B
A= $blankB= defined $separator
ABresult
1X1
011
000
147 12 ▶ $separator //= "" if $blank;
Branch: 1 branch
BranchTrueFalseTotal
if $blank 1 11 12
Condition50%1/2
$separator //= ""
l!l
01
MC/DC0%0/1
$separator //= ""
$separator
Truth table50%1/2
A
A= $separator
Aresult
11
00
148 149 ▶ my $gd = sub {
Subroutine __ANON__: called CC=4 SCAR=19.2
149 149 my $l = shift;
150 149 my $t = $time->($l);
151 149 ▶ return $t if $t;
Branch: 1 branch
BranchTrueFalseTotal
if $t 55 94 149
152 94 ▶ return if $quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 94 0 94
153 0 my $msg = qq(could not find date in "$l");
154 0 ▶ if ($warn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($warn) 0 0 0
155 0 print STDERR $msg, "\n";
156 0 return;
157 }
158 0 print STDERR $msg, "\n";
159 0 exit;
160 12 };
161 12 my @include = @$include;
162 12 my @exclude = @$exclude;
163 12 my ( $previous, @bbuf, $abuf );
164 55 ▶ my $buffer = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
165 55 my ( $line, $lineno ) = @_;
166 55 ▶ if ($abuf) {
Branch: 2 branches
BranchTrueFalseTotal
if ($abuf) { } 4 51 55
elsif ($before) { } 24 27 51
167 4 print $code->( $line, $lineno ), "\n";
168 4 $previous = $lineno;
169 4 $abuf--;
170 }
171 elsif ($before) {
172 24 my $pair = [ $line, $lineno ];
173 24 push @bbuf, $pair;
174 24 ▶ shift @bbuf if @bbuf > $before;
Branch: 1 branch
BranchTrueFalseTotal
if @bbuf > $before 16 8 24
175 }
176 12 };
177 34 ▶ my $printline = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
178 34 my ( $line, $lineno, $match ) = @_;
179 34 ▶ print $separator, "\n"
Branch: 1 branch
BranchTrueFalseTotal
if $blank and $previous and $previous + 1 < $lineno 1 33 34
Condition100%6/6
$blank and $previous and $previous + 1 < $lineno
!ll&&!rl&&r
2761
$blank and $previous
!ll&&!rl&&r
2617
MC/DC100%3/3
$blank and $previous and $previous + 1 < $lineno
$blank $previous $previous + 1 < $lineno
Truth table100%4/4
A and B and C
A= $blankB= $previousC= $previous + 1 < $lineno
ABCresult
0XX0
10X0
1100
1111
180 if $blank && $previous && $previous + 1 < $lineno;
181 34 $previous = $lineno;
182 34 print $code->( $line, $lineno, $match ), "\n";
183 12 };
184 12 my $i = 0;
185 12 ▶ my $time_filter = $start || $end;
Condition66%2/3
$start || $end
l!l&&r!l&&!r
804
MC/DC50%1/2
$start || $end
$start $end
Truth table66%2/3
A || B
A= $startB= $end
ABresult
1X1
011
000
186 12 ▶ if ($time_filter) {
Branch: 1 branch
BranchTrueFalseTotal
if ($time_filter) 8 4 12
187 8 my ( $t1, $t2, $j );
188 8 for ( 0 .. $#$lines ) {
189 40 $t1 = $gd->( $lines->[$_] );
190 40 $j = $_;
191 40 ▶ last if $t1;
Branch: 1 branch
BranchTrueFalseTotal
if $t1 8 32 40
192 }
193 8 ▶ return unless $t1;
Branch: 1 branch
BranchTrueFalseTotal
unless $t1 0 8 8
194 8 for ( reverse $j .. $#$lines ) {
195 24 $t2 = $gd->( $lines->[$_] );
196 24 ▶ last if $t2;
Branch: 1 branch
BranchTrueFalseTotal
if $t2 8 16 24
197 }
198 8 ▶ $start = $t1 unless $start;
Branch: 1 branch
BranchTrueFalseTotal
unless $start 0 8 8
199 8 ▶ $end = $t2 unless $end;
Branch: 1 branch
BranchTrueFalseTotal
unless $end 0 8 8
200 8 ▶ return unless $end >= $t1;
Branch: 1 branch
BranchTrueFalseTotal
unless $end >= $t1 0 8 8
201 8 ▶ return unless $start <= $t2;
Branch: 1 branch
BranchTrueFalseTotal
unless $start <= $t2 0 8 8
202 8 $i = _get_start( $lines, $start, $t1, $t2, $gd );
203 }
204 12 ▶ if ($before) {
Branch: 1 branch
BranchTrueFalseTotal
if ($before) 4 8 12
205 4 $i -= $before;
206 4 ▶ $i = 0 if $i < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $i < 0 4 0 4
207 }
208 12 ▶ while ( my $line = $lines->[$i] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = $lines->[$i]) 89 6 95
209 89 my $lineno = $i++;
210 89 ▶ if ($time_filter) {
Branch: 1 branch
BranchTrueFalseTotal
if ($time_filter) 81 8 89
211 81 ▶ my $t = $gd->($line) // 0;
Condition100%2/2
&$gd($line) // 0
l!l
3546
MC/DC100%1/1
&$gd($line) // 0
&$gd($line)
Truth table100%2/2
A
A= &$gd($line)
Aresult
11
00
212 81 ▶ unless ($t) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($t) 46 35 81
213 46 $buffer->( $line, $lineno );
214 46 next;
215 }
216 35 ▶ if ( $t > $end ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t > $end) 7 28 35
217 7 ▶ if ( $abuf-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($abuf--) { } 1 6 7
218 1 print $code->( $line, $lineno ), "\n";
219 1 next;
220 }
221 else {
222 6 last;
223 }
224 }
225 28 ▶ if ( $t < $start ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t < $start) 5 23 28
226 5 $buffer->( $line, $lineno );
227 5 next;
228 }
229 }
230 31 my $good = !@include;
231 31 for (@include) {
232 4 ▶ if ( $line =~ $_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /$_/) 3 1 4
233 3 $good = 1;
234 3 last;
235 }
236 }
237 31 ▶ if ($good) {
Branch: 1 branch
BranchTrueFalseTotal
if ($good) 30 1 31
238 30 for (@exclude) {
239 4 ▶ if ( $line =~ $_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /$_/) 3 1 4
240 3 undef $good;
241 3 last;
242 }
243 }
244 }
245 31 ▶ if ($good) {
Branch: 1 branch
BranchTrueFalseTotal
if ($good) { } 27 4 31
246 27 $printline->(@$_) for @bbuf;
247 27 $printline->( $line, $lineno, 1 );
248 27 ▶ splice @bbuf, 0, scalar @bbuf if $before;
Branch: 1 branch
BranchTrueFalseTotal
if $before 11 16 27
249 27 $abuf = $after;
250 }
251 else {
252 4 $buffer->( $line, $lineno );
253 }
254 }
255 }
256  
257 # find the log line to begin grepping at
258 8 ▶sub _get_start {
Subroutine _get_start: called CC=14 SCAR=34.5
259 8 my ( $lines, $start, $t1, $t2, $gd ) = @_;
260 8 ▶ return 0 if $start <= $t1;
Branch: 1 branch
BranchTrueFalseTotal
if $start <= $t1 3 5 8
261 5 my $lim = $#$lines;
262 5 my ( $s, $e ) = ( [ 0, $t1 ], [ $lim, $t2 ] );
263 5 my ( $last, $revcount ) = ( -1, 0 );
264 {
265 5 my $i = _guess( $s, $e, $start );
266 9 ▶ return $i if $i == $s->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $i == $s->[0] 5 4 9
267 4 my $rev = $last == $i;
268 4 $last = $i;
269 4 ▶ if ($rev) { # if we find ourselves looping; bail out
Branch: 1 branch
BranchTrueFalseTotal
if ($rev) { } 0 4 4
270 0 $revcount++;
271 0 ▶ if ( $revcount > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($revcount > 1) 0 0 0
272 0 ▶ --$i if $i;
Branch: 1 branch
BranchTrueFalseTotal
if $i 0 0 0
273 0 return $i;
274 }
275 }
276 else {
277 4 $revcount = 0;
278 }
279 4 my $t;
280 {
281 4 $t = $gd->( $lines->[$i] );
282 4 ▶ unless ($t) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($t) 0 4 4
283 0 ▶ $i += $rev ? -1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$rev ? : 0 0 0
284 0 ▶ return 0 unless $i;
Branch: 1 branch
BranchTrueFalseTotal
unless $i 0 0 0
285 0 ▶ return $lim if $i > $lim;
Branch: 1 branch
BranchTrueFalseTotal
if $i > $lim 0 0 0
286 0 redo;
287 }
288 }
289 4 ▶ return $i if $t == $start;
Branch: 1 branch
BranchTrueFalseTotal
if $t == $start 0 4 4
290 4 ▶ if ( $t < $start ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t < $start) { } 3 1 4
291 3 $s = [ $i, $t ];
292 }
293 else {
294 1 $e = [ $i, $t ];
295 }
296 4 ▶ if ( $s->[0] == $e->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->[0] == $e->[0]) 0 4 4
297 0 ▶ --$i if $i;
Branch: 1 branch
BranchTrueFalseTotal
if $i 0 0 0
298 0 return $i;
299 }
300 4 redo;
301 }
302 }
303  
304 # estimate the next log line to try
305 9 ▶sub _guess {
Subroutine _guess: called CC=2 SCAR=7.0
306 9 my ( $s, $e, $start ) = @_;
307 9 my $delta = $start - $s->[1];
308 9 ▶ return $s->[0] unless $delta;
Branch: 1 branch
BranchTrueFalseTotal
unless $delta 0 9 9
309 9 my $diff = $e->[1] - $s->[1];
310 9 my $offset = int( ( $e->[0] - $s->[0] ) * $delta / $diff );
311 9 return $s->[0] + $offset;
312 }
313  
314 2 1;
315  
316 __END__
↑ Summary