diff _test/any.pl @ 37:c2e7f7c96bcd

performance improvements, DOM reworked (a little)
author Sergey
date Mon, 23 Nov 2009 00:59:06 +0300
parents 1828103371d0
children 16ada169ca75
line wrap: on
line diff
--- a/_test/any.pl	Fri Nov 20 16:48:08 2009 +0300
+++ b/_test/any.pl	Mon Nov 23 00:59:06 2009 +0300
@@ -3,6 +3,7 @@
 use lib '..\Lib';
 
 require IMPL::DOM::Navigator::SimpleBuilder;
+require IMPL::DOM::XMLReader;
 
 my $builder = IMPL::DOM::Navigator::SimpleBuilder->new();
     
@@ -17,7 +18,7 @@
         $builder->Back();
         $builder->NavigateCreate('lastName')->nodeValue('Gardum');
         $builder->Back();
-        for(1..10000) {
+        for(my $i = 0 ; $i < 10000; $i++) {
             $builder->NavigateCreate('address', local => 1);
                 $builder->NavigateCreate('street')->nodeValue('Hellroad');
                 $builder->Back();
@@ -27,4 +28,38 @@
         }
     $builder->Back();
     
-    print "Build: ",tv_interval($t,[gettimeofday]),"\n";
\ No newline at end of file
+    print "Build: ",tv_interval($t,[gettimeofday]),"\n";
+    
+    $t = [gettimeofday];
+    
+    my $doc = new IMPL::DOM::Document(nodeName => 'doc');
+    for(my $i = 0 ; $i < 30000; $i++) {
+        my $node = new IMPL::DOM::Node(nodeName => 'test');
+        $node->nodeValue(100);
+        $doc->appendChild($node);
+    }
+    
+    print "Create 30000 nodes: ",tv_interval($t,[gettimeofday]),"\n";
+    
+    $t = [gettimeofday];
+    $builder = IMPL::DOM::Navigator::SimpleBuilder->new();
+    my $reader = IMPL::DOM::XMLReader->new( Navigator => $builder );
+    
+    $reader->ParseFile("Resources/large.xml");
+    print "Parsing large Xml file: ",tv_interval($t,[gettimeofday]),"\n";
+    
+    my $count = selectAll($builder->Document);
+    my $len = length $builder->Document->text;
+    print "Total nodes loaded: $count, data length: $len\n";
+    
+    $t = [gettimeofday];
+    $builder = IMPL::DOM::Navigator::SimpleBuilder->new();
+    my $reader2 = IMPL::DOM::XMLReader->new( Navigator => $builder );
+    
+    $reader2->ParseFile("Resources/person_info.xml");
+    print "Parsing small Xml file: ",tv_interval($t,[gettimeofday]),"\n";
+    
+sub selectAll {
+    my $node = shift;
+    $node,map selectAll($_),@{$node->childNodes};
+}
\ No newline at end of file