2

I'm new to Perl, and I need to improve the performance of an application someone else wrote.

Following the top answer to this question, I'm trying to use DProf.

When I call the program with -d:DProf, I get the following error:

Options must be name=>value pairs (odd number supplied) at <file and line>

The relevant line contains simply

my $xml = XMLin($FileName, KeyAttr => { server => 'name' }, ForceArray => ['Package','Sensor']);

I have found that function's documentation here, and the call seems correct. More confidently, the error does not happen without the profiler. I can reliably reproduce the error and its absence simply by adding and removing the -d:DProf profiler option in between the paths of the Perl executable and the main application file.

I'm sure that the offending line is the one I presented, because I later added debugging prints around it. When the error happens, the print before this line shows up before the error message, and the print after this line does not affect the output.

Why does this happen, and how can I profile this application?

I'm using Perl 5.10.0.

Emilio M Bumachar
  • 2,532
  • 3
  • 26
  • 30
  • Heh, that `XML::Simple` is from a long ago, and with the Perl version ... locked up in a time capsule? :) However, you _can_ profile it with a modern tool and not with yet another outdated (deprecated!) piece... – zdim Jul 28 '20 at 23:21

1 Answers1

2

Devel::DProf describes itself as "a DEPRECATED Perl code profiler." With a description like that, I'd expect problems!

Use Devel::NYTProf.

ikegami
  • 367,544
  • 15
  • 269
  • 518
  • Just like Devel::DProf discourages its own use, so does XML::Simple. It's a horrible module (and it's a slow one at that!) I prefer XML::LibXML – ikegami Jul 29 '20 at 12:57