6
my $file = $ARGV[1] || 'test.xml';
7
my ( $root, $s, $s2, $s3, $usec, $usec2, $usec3, $sa, $sb, $sc, $base1, $base2, $base3 );
9
my $onlyone = $ARGV[2] ? 1 : 0;
11
tabit( "-Module-", 'load ', 'parse ', 'total' ) if ( !$onlyone );
13
exit if ( !$ARGV[0] );
15
use Time::HiRes qw(gettimeofday);
17
# For fairness; try to get the file to be read into memory cache
19
open( FILE, '<', $file ) or die "Couldn't open $!";
25
if ( $ARGV[0] * 1 >= 0 ) {
26
( $s, $usec ) = gettimeofday();
27
if ( eval('require XML::Bare;') ) {
28
( $s2, $usec2 ) = gettimeofday();
30
my $ob = new XML::Bare( file => $file );
32
( $s3, $usec3 ) = gettimeofday();
34
timeit( 'XML::Bare', 1 );
38
if ( $ARGV[0] eq '1' ) {
39
( $s, $usec ) = gettimeofday();
40
if ( eval('require XML::LibXML;') ) {
41
( $s2, $usec2 ) = gettimeofday();
43
my $parser = XML::LibXML->new();
44
my $doc = $parser->parse_file($file);
46
( $s3, $usec3 ) = gettimeofday();
47
unload('XML::LibXML');
48
timeit('XML::LibXML');
52
if ( $ARGV[0] eq '2' ) {
53
( $s, $usec ) = gettimeofday();
54
if ( eval('require XML::Parser;') ) {
55
( $s2, $usec2 ) = gettimeofday();
57
my $parser = new XML::Parser();
58
my $doc = $parser->parsefile($file);
60
( $s3, $usec3 ) = gettimeofday();
61
unload('XML::Parser');
62
timeit('XML::Parser');
66
if ( $ARGV[0] eq '3' ) {
67
( $s, $usec ) = gettimeofday();
68
if ( eval('require XML::Parser::Expat;') ) {
69
( $s2, $usec2 ) = gettimeofday();
71
my $parser = new XML::Parser::Expat();
73
$parser->setHandlers( 'Start' => \&noop, 'End' => \&noop, 'Char' => \&noop );
74
open( FOO, $file ) or die "Couldn't open $!";
78
( $s3, $usec3 ) = gettimeofday();
79
unload('XML::Parser::Expat');
80
timeit('XML::Parser::Expat');
84
if ( $ARGV[0] eq '4' ) {
85
( $s, $usec ) = gettimeofday();
86
if ( eval('require XML::Descent;') ) {
87
( $s2, $usec2 ) = gettimeofday();
89
my $p = XML::Descent->new( { Input => $file } );
92
my ( $elem, $attr ) = @_;
98
( $s3, $usec3 ) = gettimeofday();
99
unload('XML::Descent');
100
timeit('XML::Descent');
104
if ( $ARGV[0] eq '5' ) {
105
( $s, $usec ) = gettimeofday();
106
if ( eval('require XML::DOM;') ) {
107
( $s2, $usec2 ) = gettimeofday();
109
my $parser = new XML::DOM::Parser;
110
my $doc = $parser->parsefile($file); ##
112
( $s3, $usec3 ) = gettimeofday();
120
my @parts = split( ' ', $module );
122
$module =~ s/::/\//g;
124
delete $INC{$module};
130
$sa = $s2 - $s + ( ( $usec2 - $usec ) / 1000000 );
131
$sb = $s3 - $s2 + ( ( $usec3 - $usec2 ) / 1000000 );
132
$sc = $s3 - $s + ( ( $usec3 - $usec ) / 1000000 );
144
if ( !$base || !$onlyone ) {
145
tabit( $name, $sa, $sb, $sc );
150
my ( $a, $b, $c, $d ) = @_;
151
my $len = length($a);
153
for ( 0 .. ( $maxlen - $len ) ) { print ' '; }
163
my $len = length($a);
164
if ( $len > 8 ) { $a = substr( $a, 8 ); }