This file is indexed.

/usr/share/perl5/IPC/Run3/ProfReporter.pm is in libipc-run3-perl 0.048-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
package IPC::Run3::ProfReporter;

$VERSION = 0.048;

=head1 NAME

IPC::Run3::ProfReporter - base class for handling profiling data

=head1 SYNOPSIS

=head1 DESCRIPTION

See L<IPC::Run3::ProfPP|IPC::Run3::ProfPP> and for an example subclass.

This class just notes and accumulates times; subclasses use methods like
"handle_app_call", "handle_run_exit" and "handle_app_exit" to emit reports on
it.  The default methods for these handlers are noops.

If run from the command line, a reporter will be created and run on
each logfile given as a command line parameter or on run3.out if none
are given.

This allows reports to be run like:

    perl -MIPC::Run3::ProfPP -e1
    perl -MIPC::Run3::ProfPP -e1 foo.out bar.out

Use "-" to read from STDIN (the log file format is meant to be moderately
greppable):

    grep "^cvs " run3.out perl -MIPC::Run3::ProfPP -e1 -

Use --app to show only application level statistics (ie don't emit
a report section for each command run).

=cut

use strict;

my $loaded_by;

sub import {
    $loaded_by = shift;
}

END {
    my @caller;
    for ( my $i = 0;; ++$i ) {
        my @c = caller $i;
        last unless @c;
        @caller = @c;
    }

    if ( $caller[0] eq "main"
        && $caller[1] eq "-e"
    ) {
        require IPC::Run3::ProfLogReader;
        require Getopt::Long;
        my ( $app, $run );

        Getopt::Long::GetOptions(
            "app" => \$app,
            "run" => \$run,
        );

        $app = 1, $run = 1 unless $app || $run;

        for ( @ARGV ? @ARGV : "" ) {
            my $r = IPC::Run3::ProfLogReader->new(
                Source  => $_,
                Handler => $loaded_by->new(
                    Source => $_,
                    app_report => $app,
                    run_report => $run,
                ),
            );
            $r->read_all;
        }
    }
}

=head1 METHODS

=over

=item C<< IPC::Run3::ProfReporter->new >>

Returns a new profile reporting object.

=cut

sub new {
    my $class = ref $_[0] ? ref shift : shift;
    my $self = bless { @_ }, $class;
    $self->{app_report} = 1, $self->{run_report} = 1
        unless $self->{app_report} || $self->{run_report};

    return $self;
}

=item C<< $reporter->handle_app_call( ... ) >>

=item C<< $reporter->handle_app_exit( ... ) >>

=item C<< $reporter->handle_run_exit( ... ) >>

These methods are called by the handled events (see below).

=cut

sub handle_app_call {}
sub handle_app_exit {}

sub handle_run_exit {}

=item C<< $reporter->app_call(\@cmd, $time) >>

=item C<< $reporter->app_exit($time) >>

=item C<< $reporter->run_exit(@times) >>

   $self->app_call( $time );
   my $time = $self->get_app_call_time;

Sets the time (in floating point seconds) when the application, run3(),
or system() was called or exited.  If no time parameter is passed, uses
IPC::Run3's time routine.

Use get_...() to retrieve these values (and _accum values, too).  This
is a separate method to speed the execution time of the setters just a
bit.

=cut

sub app_call {
    my $self = shift;
    ( $self->{app_cmd}, $self->{app_call_time} ) = @_;
    $self->handle_app_call if $self->{app_report};
}

sub app_exit {
    my $self = shift;
    $self->{app_exit_time} = shift;
    $self->handle_app_exit if $self->{app_report};
}

sub run_exit {
    my $self = shift;
    @{$self}{qw(
        run_cmd run_call_time sys_call_time sys_exit_time run_exit_time
    )} = @_;

    ++$self->{run_count};
    $self->{run_cumulative_time} += $self->get_run_time;
    $self->{sys_cumulative_time} += $self->get_sys_time;
    $self->handle_run_exit if $self->{run_report};
}

=item C<< $reporter->get_run_count() >>

=item C<< $reporter->get_app_call_time() >>

=item C<< $reporter->get_app_exit_time() >>

=item C<< $reporter->get_app_cmd() >>

=item C<< $reporter->get_app_time() >>

=cut

sub get_run_count     { shift->{run_count} }
sub get_app_call_time { shift->{app_call_time} }
sub get_app_exit_time { shift->{app_exit_time} }
sub get_app_cmd       { shift->{app_cmd}       }
sub get_app_time {
    my $self = shift;
    $self->get_app_exit_time - $self->get_app_call_time;
}

=item C<< $reporter->get_app_cumulative_time() >>

=cut

sub get_app_cumulative_time {
    my $self = shift;
    $self->get_app_exit_time - $self->get_app_call_time;
}

=item C<< $reporter->get_run_call_time() >>

=item C<< $reporter->get_run_exit_time() >>

=item C<< $reporter->get_run_time() >>

=cut

sub get_run_call_time { shift->{run_call_time} }
sub get_run_exit_time { shift->{run_exit_time} }
sub get_run_time {
    my $self = shift;
    $self->get_run_exit_time - $self->get_run_call_time;
}

=item C<< $reporter->get_run_cumulative_time() >>

=cut

sub get_run_cumulative_time { shift->{run_cumulative_time} }

=item C<< $reporter->get_sys_call_time() >>

=item C<< $reporter->get_sys_exit_time() >>

=item C<< $reporter->get_sys_time() >>

=cut

sub get_sys_call_time { shift->{sys_call_time} }
sub get_sys_exit_time { shift->{sys_exit_time} }
sub get_sys_time {
    my $self = shift;
    $self->get_sys_exit_time - $self->get_sys_call_time;
}

=item C<< $reporter->get_sys_cumulative_time() >>

=cut

sub get_sys_cumulative_time { shift->{sys_cumulative_time} }

=item C<< $reporter->get_run_cmd() >>

=cut

sub get_run_cmd { shift->{run_cmd} }

=back

=head1 LIMITATIONS

=head1 COPYRIGHT

    Copyright 2003, R. Barrie Slaymaker, Jr., All Rights Reserved

=head1 LICENSE

You may use this module under the terms of the BSD, Artistic, or GPL licenses,
any version.

=head1 AUTHOR

Barrie Slaymaker <barries@slaysys.com>

=cut

1;