Run3/ProfLogger.pm

filter: Statementstmt 22.2% 8 / 36 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 33.3% 2 / 6 Podpod 100% 4 / 4 totaltotal 24.5% 14 / 57 CC 5 SCAR 27.6
CC
5
Cov
18%
new
30.0
run_exit
2.0
app_exit
2.0
CRAP 15.8
« Run3.pm ↑ Summary Run3/ProfLogReader.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package IPC::Run3::ProfLogger;
4  
5 1 our $VERSION = 0.049;
6  
7 =head1 NAME
8  
9 IPC::Run3::ProfLogger - write profiling data to a log file
10  
11 =head1 SYNOPSIS
12  
13 use IPC::Run3::ProfLogger;
14  
15 my $logger = IPC::Run3::ProfLogger->new; ## write to "run3.out"
16 my $logger = IPC::Run3::ProfLogger->new( Destination => $fn );
17  
18 $logger->app_call( \@cmd, $time );
19  
20 $logger->run_exit( \@cmd1, @times1 );
21 $logger->run_exit( \@cmd1, @times1 );
22  
23 $logger->app_exit( $time );
24  
25 =head1 DESCRIPTION
26  
27 Used by IPC::Run3 to write a profiling log file. Does not
28 generate reports or maintain statistics; its meant to have minimal
29 overhead.
30  
31 Its API is compatible with a tiny subset of the other IPC::Run profiling
32 classes.
33  
34 =cut
35  
36 =head1 METHODS
37  
38 =head2 C<< IPC::Run3::ProfLogger->new( ... ) >>
39  
40 =cut
41  
42 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
43 0 ▶ my $class = ref $_[0] ? ref shift : shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
44 0 my $self = bless { @_ }, $class;
45  
46 $self->{Destination} = "run3.out"
47 0 ▶ unless defined $self->{Destination} && length $self->{Destination};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"Destination"} and length $self->{"Destination"} 0 0 0
Condition0%0/3
defined $self->{"Destination"} and length $self->{"Destination"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"Destination"} and length $self->{"Destination"}
defined $self->{"Destination"} length $self->{"Destination"}
Truth table0%0/3
A and B
A= defined $self->{"Destination"}B= length $self->{"Destination"}
ABresult
0X0
100
111
48  
49 0 ▶ open PROFILE, ">$self->{Destination}"
Branch: 1 branch
BranchTrueFalseTotal
open PROFILE, qq[>$self->{"Destination"}] or die qq[$!: $self->{"Destination"}\n] 0 0 0
50 or die "$!: $self->{Destination}\n";
51 0 binmode PROFILE;
52 0 $self->{FH} = *PROFILE{IO};
53  
54 0 $self->{times} = [];
55 0 return $self;
56 }
57  
58 =head2 C<< $logger->run_exit( ... ) >>
59  
60 =cut
61  
62 0 ▶sub run_exit {
Subroutine run_exit: not called CC=1 SCAR=6.9
Pod documented
63 0 my $self = shift;
64 0 my $fh = $self->{FH};
65 print( $fh
66 join(
67 " ",
68 (
69 map {
70 0 my $s = $_;
71 0 $s =~ s/\\/\\\\/g;
72 0 $s =~ s/ /_/g;
73 0 $s;
74 0 } @{shift()}
75 ),
76 join(
77 ",",
78 0 @{$self->{times}},
79 @_,
80 ),
81 ),
82 "\n"
83 );
84 }
85  
86 =head2 C<< $logger->app_exit( $arg ) >>
87  
88 =cut
89  
90 0 ▶sub app_exit {
Subroutine app_exit: not called CC=1 SCAR=6.9
Pod documented
91 0 my $self = shift;
92 0 my $fh = $self->{FH};
93 0 print $fh "\\app_exit ", shift, "\n";
94 }
95  
96 =head2 C<< $logger->app_call( $t, @args) >>
97  
98 =cut
99  
100 0 ▶sub app_call {
Subroutine app_call: not called CC=1 SCAR=6.9
Pod documented
101 0 my $self = shift;
102 0 my $fh = $self->{FH};
103 0 my $t = shift;
104 print( $fh
105 join(
106 " ",
107 "\\app_call",
108 (
109 map {
110 0 my $s = $_;
111 0 $s =~ s/\\\\/\\/g;
112 0 $s =~ s/ /\\_/g;
113 0 $s;
114 } @_
115 ),
116 $t,
117 ),
118 "\n"
119 );
120 }
121  
122 =head1 LIMITATIONS
123  
124 =head1 COPYRIGHT
125  
126 Copyright 2003, R. Barrie Slaymaker, Jr., All Rights Reserved
127  
128 =head1 LICENSE
129  
130 You may use this module under the terms of the BSD, Artistic, or GPL licenses,
131 any version.
132  
133 =head1 AUTHOR
134  
135 Barrie Slaymaker E<lt>barries@slaysys.comE<gt>
136  
137 =cut
138  
139 1 1;
« Run3.pm ↑ Summary Run3/ProfLogReader.pm »