blib/lib/Net/Write/Fast.pm

filter: Statementstmt 45.4% 20 / 44 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 28.8% 26 / 90 CC 12 SCAR 36.4
CC
12
Cov
27%
runtime_as_string
56.0
estimate_runtime
42.0
BEGIN
1.0
CRAP 38.1
↑ Summary Fast.xs »
1 #
2 # $Id: Fast.pm,v 83433f6e04ef 2016/02/04 06:28:41 gomor $
3 #
4 package Net::Write::Fast;
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use base qw(Exporter DynaLoader);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '0.18';
11  
12 4 __PACKAGE__->bootstrap($VERSION);
13  
14 4 our %EXPORT_TAGS = (
15 consts => [qw(
16 )],
17 subs => [qw(
18 estimate_runtime
19 runtime_as_string
20 )],
21 vars => [qw(
22 )],
23 );
24  
25 our @EXPORT_OK = (
26 4 @{$EXPORT_TAGS{vars}},
27 4 @{$EXPORT_TAGS{consts}},
28 4 @{$EXPORT_TAGS{subs}},
29 );
30  
31 4 ▶use Time::Interval;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 0 ▶sub estimate_runtime {
Subroutine estimate_runtime: not called CC=6 SCAR=37.4
Pod documented
34 0 my ($info) = @_;
35  
36 0 ▶ if (! defined($info)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $info) 0 0 0
37 0 print STDERR "[-] estimate_runtime: give HASHREF\n";
38 0 return;
39 }
40  
41 0 ▶ if (! exists($info->{ports})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $info->{"ports"} and exists $info->{"targets"} and exists $info->{"try"} and exists $info->{"pps"}) 0 0 0
Condition0%0/9
exists $info->{"ports"} and exists $info->{"targets"} and exists $info->{"try"} and exists $info->{"pps"}
!ll&&!rl&&r
000
exists $info->{"ports"} and exists $info->{"targets"} and exists $info->{"try"}
!ll&&!rl&&r
000
exists $info->{"ports"} and exists $info->{"targets"}
!ll&&!rl&&r
000
MC/DC0%0/4
exists $info->{"ports"} and exists $info->{"targets"} and exists $info->{"try"} and exists $info->{"pps"}
exists $info->{"ports"} exists $info->{"targets"} exists $info->{"try"} exists $info->{"pps"}
Truth table0%0/5
A and B and C and D
A= exists $info->{"ports"}B= exists $info->{"targets"}C= exists $info->{"try"}D= exists $info->{"pps"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
42 || ! exists($info->{targets})
43 || ! exists($info->{try})
44 || ! exists($info->{pps})) {
45 0 print STDERR "[-] estimate_runtime: info HASHREF not complete\n";
46 0 return;
47 }
48  
49 0 my $nports = scalar(@{$info->{ports}});
50 0 my $nhosts = scalar(@{$info->{targets}});
51 0 my $try = $info->{try};
52 0 my $pps = $info->{pps};
53  
54 0 my $estim = Time::Interval::parseInterval(
55 seconds => $try * $nports * $nhosts / $pps,
56 );
57  
58 return {
59 days => $estim->{days},
60 hours => $estim->{hours},
61 minutes => $estim->{minutes},
62 seconds => $estim->{seconds},
63 0 nhosts => $nhosts,
64 };
65 }
66  
67 0 ▶sub runtime_as_string {
Subroutine runtime_as_string: not called CC=7 SCAR=40.3
Pod documented
68 0 my ($info) = @_;
69  
70 0 ▶ if (! defined($info)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $info) 0 0 0
71 0 print STDERR "[-] runtime_as_string: give HASHREF\n";
72 0 return;
73 }
74  
75 0 ▶ if (! exists($info->{days})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $info->{"days"} and exists $info->{"hours"} and exists $info->{"minutes"} and exists $info->{"seconds"} and exists $info->{"nhosts"}) 0 0 0
Condition0%0/12
exists $info->{"days"} and exists $info->{"hours"} and exists $info->{"minutes"} and exists $info->{"seconds"} and exists $info->{"nhosts"}
!ll&&!rl&&r
000
exists $info->{"days"} and exists $info->{"hours"} and exists $info->{"minutes"} and exists $info->{"seconds"}
!ll&&!rl&&r
000
exists $info->{"days"} and exists $info->{"hours"} and exists $info->{"minutes"}
!ll&&!rl&&r
000
exists $info->{"days"} and exists $info->{"hours"}
!ll&&!rl&&r
000
MC/DC0%0/5
exists $info->{"days"} and exists $info->{"hours"} and exists $info->{"minutes"} and exists $info->{"seconds"} and exists $info->{"nhosts"}
exists $info->{"days"} exists $info->{"hours"} exists $info->{"minutes"} exists $info->{"seconds"} exists $info->{"nhosts"}
Truth table0%0/6
A and B and C and D and E
A= exists $info->{"days"}B= exists $info->{"hours"}C= exists $info->{"minutes"}D= exists $info->{"seconds"}E= exists $info->{"nhosts"}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
76 || ! exists($info->{hours})
77 || ! exists($info->{minutes})
78 || ! exists($info->{seconds})
79 || ! exists($info->{nhosts})) {
80 0 print STDERR "[-] runtime_as_string: info HASHREF not complete\n";
81 0 return;
82 }
83  
84 my $string = sprintf(
85 "Estimated runtime: %d day(s) %d hour(s) %d minute(s) %d second(s) for %d host(s)",
86 $info->{days},
87 $info->{hours},
88 $info->{minutes},
89 $info->{seconds},
90 $info->{nhosts},
91 0 );
92  
93 0 return $string;
94 }
95  
96 4 1;
97  
98 __END__
↑ Summary Fast.xs »