Sorry, they are the same scripts as published earlier in the thread with the addition of a couple of timing points.
But here ya go. Using LibXML:
#! perl -slw
use strict;
use Data::Dump qw[ pp ];
use Time::HiRes qw[ time ];
use XML::LibXML;
open XML, '<', $ARGV[0] or die $!;
my $start = time;
my $root = XML::LibXML->load_xml( IO => \*XML )->documentElement;
printf "Parsing took %.6f seconds\n", time - $start;
my $start2 = time;
for my $station ($root->findnodes('*')) {
my $x = $station->nodeName;
for my $ip ( $station->findnodes('ip') ) {
$x = $ip->textContent;
}
}
printf "Iteration took %.6f seconds\n", time - $start2;
printf "Total took %.6f seconds\n", time - $start;
printf 'Check mem:'; <STDIN>;
And XML::Simple: #! perl -slw
use strict;
use Data::Dump qw[ pp ];
use Time::HiRes qw[ time ];
use XML::Simple;
open XML, '<', $ARGV[0] or die $!;
my $start = time;
my $stations = XMLin( \*XML, ForceArray => [ 'ip'], NoAttr => 1 );
printf "Parsing took %.6f seconds\n", time - $start;
my $start2 = time;
for my $station ( keys %$stations ) {
my $x = $station;
for my $ip ( @{ $stations->{ $station }{ip} } ) {
$x = $ip;
}
}
printf "Iteration took %.6f seconds\n", time - $start2;
printf "Total took %.6f seconds\n", time - $start;
printf 'Check mem:'; <STDIN>;
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
|