line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IPC::Run3::ProfLogger; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 0.048; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
IPC::Run3::ProfLogger - write profiling data to a log file |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use IPC::Run3::ProfLogger; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $logger = IPC::Run3::ProfLogger->new; ## write to "run3.out" |
14
|
|
|
|
|
|
|
my $logger = IPC::Run3::ProfLogger->new( Destination => $fn ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$logger->app_call( \@cmd, $time ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$logger->run_exit( \@cmd1, @times1 ); |
19
|
|
|
|
|
|
|
$logger->run_exit( \@cmd1, @times1 ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$logger->app_exit( $time ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Used by IPC::Run3 to write a profiling log file. Does not |
26
|
|
|
|
|
|
|
generate reports or maintain statistics; its meant to have minimal |
27
|
|
|
|
|
|
|
overhead. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Its API is compatible with a tiny subset of the other IPC::Run profiling |
30
|
|
|
|
|
|
|
classes. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
5183
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
425
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 C<< IPC::Run3::ProfLogger->new( ... ) >> |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
0
|
0
|
|
0
|
1
|
|
my $class = ref $_[0] ? ref shift : shift; |
44
|
0
|
|
|
|
|
|
my $self = bless { @_ }, $class; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
0
|
|
|
|
$self->{Destination} = "run3.out" |
47
|
|
|
|
|
|
|
unless defined $self->{Destination} && length $self->{Destination}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
open PROFILE, ">$self->{Destination}" |
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
|
|
|
|
|
|
|
sub run_exit { |
63
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
my $fh = $self->{FH}; |
65
|
0
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub app_exit { |
91
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub app_call { |
101
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
102
|
0
|
|
|
|
|
|
my $fh = $self->{FH}; |
103
|
0
|
|
|
|
|
|
my $t = shift; |
104
|
0
|
|
|
|
|
|
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 Ebarries@slaysys.comE |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |