in reply to XMLin slow in debug mode?

I can't reproduce the slowdown you report. Adding a little crude timing code to your script

my $start = times; my $config = XMLin($data); my $stop = times; print "$start:$stop: ",$stop - $start; print "config read\n";

It seems to show that it takes just over twice as long to run under the debugger as not

P:\test>junk 0.39:1.381: 0.991 config read P:\test>perl -d junk.pl8 Loading DB routines from perl5db.pl version 1.19 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(junk.pl8:5): my $data; main::(junk.pl8:6): { DB<1> c 14 1.792:3.945: 2.153 main::(junk.pl8:14): print "config read\n"; DB<2>

which seems reasonable and nowhere near the 30 seconds you are seeing.

Perhaps you have some PERL5DB_OPTS set that could account for it?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Replies are listed 'Best First'.
Re: Re: XMLin slow in debug mode?
by tall_man (Parson) on Jul 09, 2003 at 19:25 UTC
    I don't have any extra PERL5DB_OPTS set. It may be a difference in the XML::Simple configuration I'm using. Here's part of a stack trace during the slowdown:
    = utf8::SWASHNEW('utf8', '', '# comment^J0100^I0131^J0134^I013e^J0141 +^I0148^J', 1, 0) called from file `/opt/acs/perl/lib/perl5/site_perl/ +5.8.0/XML/SAX/PurePerl/Reader.pm' line 115 $ = XML::SAX::PurePerl::Reader::match_re(ref(XML::SAX::PurePerl::Reade +r::String), ref(Regexp)) called from file `/opt/acs/perl/lib/perl5/si +te_perl/5.8.0/XML/SAX/PurePerl/Reader.pm' line 256 . = XML::SAX::PurePerl::Reader::consume(ref(XML::SAX::PurePerl::Reader +::String), ref(Regexp)) called from file `/opt/acs/perl/lib/perl5/sit +e_perl/5.8.0/XML/SAX/PurePerl/Reader.pm' line 246 $ = XML::SAX::PurePerl::Reader::consume_name(ref(XML::SAX::PurePerl::R +eader::String)) called from file `/opt/acs/perl/lib/perl5/site_perl/5 +.8.0/XML/SAX/PurePerl.pm' line 677 $ = XML::SAX::PurePerl::Name(ref(XML::SAX::PurePerl), ref(XML::SAX::Pu +rePerl::Reader::String)) called from file `/opt/acs/perl/lib/perl5/si +te_perl/5.8.0/XML/SAX/PurePerl.pm' line 555 @ = XML::SAX::PurePerl::Attribute(ref(XML::SAX::PurePerl), ref(XML::SA +X::PurePerl::Reader::String)) called from file `/opt/acs/perl/lib/per +l5/site_perl/5.8.0/XML/SAX/PurePerl.pm' line 163 $ = XML::SAX::PurePerl::element(ref(XML::SAX::PurePerl), ref(XML::SAX: +:PurePerl::Reader::String)) called from file `/opt/acs/perl/lib/perl5 +/site_perl/5.8.0/XML/SAX/PurePerl.pm' line 269 . = XML::SAX::PurePerl::content(ref(XML::SAX::PurePerl), ref(XML::SAX: +:PurePerl::Reader::String)) called from file `/opt/acs/perl/lib/perl5 +/site_perl/5.8.0/XML/SAX/PurePerl.pm' line 239 $ = XML::SAX::PurePerl::element(ref(XML::SAX::PurePerl), ref(XML::SAX: +:PurePerl::Reader::String)) called from file `/opt/acs/perl/lib/perl5 +/site_perl/5.8.0/XML/SAX/PurePerl.pm' line 130 . = XML::SAX::PurePerl::document(ref(XML::SAX::PurePerl), ref(XML::SAX +::PurePerl::Reader::String)) called from file `/opt/acs/perl/lib/perl +5/site_perl/5.8.0/XML/SAX/PurePerl.pm' line 102 $ = XML::SAX::PurePerl::_parse(ref(XML::SAX::PurePerl), ref(XML::SAX:: +PurePerl::Reader::String)) called from file `/opt/acs/perl/lib/perl5/ +site_perl/5.8.0/XML/SAX/PurePerl.pm' line 64 $ = XML::SAX::PurePerl::_parse_string(ref(XML::SAX::PurePerl), '<confi +g ....>') ... called from file `/opt/acs/perl/lib/perl5/site_perl/5.8 +.0/XML/SAX/Base.pm' line 2302
    Would it be slow because I'm using XML::SAX::PurePerl?

    Update: I just installed XML::SAX::Expat, and now the line executes quickly. Thanks for your help, everyone.

      That seems like a strong possibility. When you use one of the C-library versions of XML::Parser, once you enter the library calls, the debugger wouldn't do much until you exit again. With the pure perl version, the debugger is probably interceding at each level of function call, if not every line.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller