← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:35 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Base.pm
StatementsExecuted 23 statements in 1.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.45ms3.56msTapper::Base::::BEGIN@12Tapper::Base::BEGIN@12
111835µs1.54msTapper::Base::::BEGIN@11Tapper::Base::BEGIN@11
111256µs271µsTapper::Base::::BEGIN@14Tapper::Base::BEGIN@14
11147µs98µsTapper::Base::::BEGIN@16Tapper::Base::BEGIN@16
11110µs4.15msTapper::Base::::BEGIN@10Tapper::Base::BEGIN@10
11110µs10µsTapper::Base::::BEGIN@2Tapper::Base::BEGIN@2
1119µs51µsTapper::Base::::BEGIN@16.2Tapper::Base::BEGIN@16.2
0000s0sTapper::Base::::kill_instanceTapper::Base::kill_instance
0000s0sTapper::Base::::log_and_execTapper::Base::log_and_exec
0000s0sTapper::Base::::makedirTapper::Base::makedir
0000s0sTapper::Base::::run_oneTapper::Base::run_one
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Tapper::Base;
2
# spent 10µs within Tapper::Base::BEGIN@2 which was called: # once (10µs+0s) by base::import at line 4
BEGIN {
314µs $Tapper::Base::AUTHORITY = 'cpan:AMD';
4124µs110µs}
# spent 10µs making 1 call to Tapper::Base::BEGIN@2
5{
621µs $Tapper::Base::VERSION = '4.1.3';
7}
8# ABSTRACT: Tapper - Common functions for all Tapper classes
9
10353µs28.30ms
# spent 4.15ms (10µs+4.14) within Tapper::Base::BEGIN@10 which was called: # once (10µs+4.14ms) by base::import at line 10
use Moose;
# spent 4.15ms making 1 call to Tapper::Base::BEGIN@10 # spent 4.14ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:492]
113155µs21.84ms
# spent 1.54ms (835µs+701µs) within Tapper::Base::BEGIN@11 which was called: # once (835µs+701µs) by base::import at line 11
use Fcntl;
# spent 1.54ms making 1 call to Tapper::Base::BEGIN@11 # spent 307µs making 1 call to Exporter::import
123116µs23.58ms
# spent 3.56ms (2.45+1.11) within Tapper::Base::BEGIN@12 which was called: # once (2.45ms+1.11ms) by base::import at line 12
use LockFile::Simple;
# spent 3.56ms making 1 call to Tapper::Base::BEGIN@12 # spent 22µs making 1 call to Exporter::import
13
143267µs2286µs
# spent 271µs (256+15) within Tapper::Base::BEGIN@14 which was called: # once (256µs+15µs) by base::import at line 14
use common::sense;
# spent 271µs making 1 call to Tapper::Base::BEGIN@14 # spent 15µs making 1 call to common::sense::import
15
166451µs3191µs
# spent 51µs (9+42) within Tapper::Base::BEGIN@16.2 which was called: # once (9µs+42µs) by Tapper::Base::BEGIN@16 at line 16 # spent 98µs (47+51) within Tapper::Base::BEGIN@16 which was called: # once (47µs+51µs) by base::import at line 16
use 5.010;
# spent 98µs making 1 call to Tapper::Base::BEGIN@16 # spent 51µs making 1 call to Tapper::Base::BEGIN@16.2 # spent 42µs making 1 call to feature::import
17
1814µs143.5mswith 'MooseX::Log::Log4perl';
# spent 43.5ms making 1 call to Moose::with
19
20
21sub kill_instance
22{
23 my ($self, $pid_file) = @_;
24
25 # try to kill previous incarnations
26 if ((-e $pid_file) and open(my $fh, "<", $pid_file)) {{
27 my $pid = do {local $\; <$fh>}; # slurp
28 ($pid) = $pid =~ m/(\d+)/;
29 last unless $pid;
30 kill 15, $pid;
31 sleep(2);
32 kill 9, $pid;
33 close $fh;
34 }}
35 return 0;
36
37}
38
39
40sub run_one
41{
42 my ($self, $conf) = @_;
43
44 my $command = $conf->{command};
45 my $pid_file = $conf->{pid_file};
46 my @argv = @{$conf->{argv} // [] } ;
47
48 $self->kill_instance($pid_file);
49
50 return qq(Can not execute "$command" because it's not an executable) unless -x $command;
51 my $pid = fork();
52 return qq(Can not execute "$command". Fork failed: $!) unless defined $pid;
53
54 if ($pid == 0) {
55 exec $command, @argv;
56 exit 0;
57 }
58
59 return 0 unless $pid_file;
60 open(my $fh, ">", $pid_file) or return qq(Can not open "$pid_file" for pid $pid:$!);
61 print $fh $pid;
62 close $fh;
63 return 0;
64}
65
- -
69sub makedir
70{
71 my ($self, $dir) = @_;
72 return 0 if -d $dir;
73 if (-e $dir and not -d $dir) {
74 unlink $dir;
75 }
76 system("mkdir","-p",$dir) == 0 or return "Can't create $dir:$!";
77 return 0;
78}
79
- -
82sub log_and_exec
83{
84 my ($self, @cmd) = @_;
85 my $cmd = join " ",@cmd;
86 $self->log->debug( $cmd );
87 my $output=`$cmd 2>&1`;
88 my $retval=$?;
89 if (not defined($output)) {
90 $output = "Executing $cmd failed";
91 $retval = 1;
92 }
93 chomp $output if $output;
94 if ($retval) {
95 return ($retval >> 8, $output) if wantarray;
96 return $output;
97 }
98 return (0, $output) if wantarray;
99 return 0;
100}
101
10219µs1; # End of Tapper::Base
103
104__END__