Perl script clarification -


i have following perl script , observed statement @ line number 5 taking 30 sec execute. not have clue how investigate why taking time.

can please suggest me on reason?

sub parse {    $self = shift;    $parse_options = $self->get_options(@_);    $method = $self->can('_parse_systemid');    return $method->($self, $parse_options->{source}{systemid});  # takes 30 s } 

the code provided:

sub parse {    $self = shift;    $parse_options = $self->get_options(@_);    $method = $self->can('_parse_systemid')    return $method->($self, $parse_options->{source}{systemid});  # takes 30 s } 

can refactored this:

sub parse {   $self = shift;   $parse_options = $self->get_options(@_);   return $self->_parse_systemid( $parse_options->{source}{systemid} ); # still takes 30s. } 

in either case, if _parse_systemid isn't member function of object referred $self, script dies, use of can useless.

anyway, code taking long time execute still takes long time in refactored code. line still problem you:

return $self->_parse_systemid( $parse_options->{source}{systemid} ); # still takes 30s. 

let's refactor bit make clearer:

my $systemid = $parse_options->{source}{systemid}; $rv = $self->_parse_systemid( $systemid ); # still takes 30s. return $rv; 

now becomes pretty clear taking 30 seconds call $self->_parse_systemid(). need looking @ happens inside _parse_systemid method of class referred $self.

it might useful invoke assistance of devel::nytprof, allow drill down _parse_systemid see taking long there.

we cannot provide definitive answer because code posted doesn't contain problem. such, strictly speaking, it's unanswerable question, asked. however, believe recommendations given in answer put on right track.

update: kjpirs mentioned in comment, , correct: _parse_systemid comes xml::sax::pureperl or xml::libxml::sax. convention, subroutines start underscore intended private class or object. usage risky; when use functions not part of public api object or class, bets off -- you've ventured out on own.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -