findvalue is very slow
Vincent Lefevre <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Is there any reason why findvalue is very slow?
For instance, running the following script on some SVN log file
(produced by "svn log --xml") gives:
0.07 0.01 (0)
0.56 0.01 (5360)
0.60 0.01 (5360)
15.95 0.01 (5360)
This has been tested on a Debian/unstable machine (x86_64).
#!/usr/bin/perl
use strict;
use XML::LibXML;
@ARGV == 1 or die "Usage: bench-findvalue <svn-logfile.xml>\n";
my $parser = XML::LibXML->new();
my $xml = $parser->parse_file($ARGV[0]);
my $c = 0;
sub ptimes
{ printf "%6.2f %6.2f (%s)\n", (times)[0,1], $c }
ptimes;
foreach my $node ($xml->findnodes('/log/logentry/date/text()'))
{
my $date = $node->nodeValue;
$c++;
}
ptimes;
$c = 0;
foreach my $node ($xml->findnodes('/log/logentry/date'))
{
my $date = $node->textContent;
$c++;
}
ptimes;
$c = 0;
foreach my $node ($xml->findnodes('/log/logentry'))
{
my $date = $node->findvalue('date');
$c++;
}
ptimes;
--
Vincent Lefèvre <[email protected]> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs