[gxml] Added performance test for GDocument



commit 5f3b839d16aa839d252b7ad3f8e93687ca83ba9c
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon Feb 8 17:39:07 2016 -0600

    Added performance test for GDocument
    
    * Found equivalent time response vs. xDocument

 gxml/libxml-BackedNode.vala    |    1 -
 gxml/libxml-ChildNodeList.vala |    1 -
 test/gxml-performance.vala     |   30 ++++++++++++++++++++++++++----
 3 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/gxml/libxml-BackedNode.vala b/gxml/libxml-BackedNode.vala
index 19d2cfe..69e89a6 100644
--- a/gxml/libxml-BackedNode.vala
+++ b/gxml/libxml-BackedNode.vala
@@ -52,7 +52,6 @@ namespace GXml {
                        this.set_xmlnode (node, owner);
                        // TODO: Consider checking whether the Xml.Node* is already recorded.  It shouldn't 
be.
                        // TODO: BackedNodes' memory are freed when their owner document is freed; let's make 
sure that when we move a node between documents, that we make sure they'll still be freed
-                       Test.message ("Getting NodeChildNodeList for node: "+name);
                        _child_nodes = new NodeChildNodeList (this.node, this.owner_document);
                }
 
diff --git a/gxml/libxml-ChildNodeList.vala b/gxml/libxml-ChildNodeList.vala
index 75a7d40..09f3a53 100644
--- a/gxml/libxml-ChildNodeList.vala
+++ b/gxml/libxml-ChildNodeList.vala
@@ -80,7 +80,6 @@ internal abstract class GXml.ChildNodeList : AbstractBidirList<xNode>, xNodeList
                public override new xNode @get (int n)
             requires (head != null)
         {
-          Test.message ("Searching for node at: "+n.to_string ());
             Xml.Node *cur = head;
             int i = 0;
             while (cur != null) {
diff --git a/test/gxml-performance.vala b/test/gxml-performance.vala
index eb1e855..5394e77 100644
--- a/test/gxml-performance.vala
+++ b/test/gxml-performance.vala
@@ -119,10 +119,16 @@ class BookStore : SerializableContainer
 
 public class Performance
 {
+  public static void iterate (Document doc) {
+    foreach (GXml.Node node in doc.root.children) {
+      string n = node.name;
+      string v = node.value;
+    }
+  }
   public static void add_tests ()
   {
 #if ENABLE_PERFORMANCE_TESTS
-    Test.add_func ("/gxml/performance/document", 
+    Test.add_func ("/gxml/performance/read/xdocument", 
     () => {
       try {
         Test.timer_start ();
@@ -131,9 +137,25 @@ public class Performance
         time = Test.timer_elapsed ();
         Test.minimized_result (time, "Load large document: %g seconds", time);
         Test.timer_start ();
-        foreach (GXml.xNode n in ((GXml.xNode)d.document_element).child_nodes) {
-          if (n.node_name == "Book1") { /* Fake just to access the node */ }
-        }
+        iterate (d);
+        time = Test.timer_elapsed ();
+        Test.minimized_result (time, "Itirate over all loaded nodes: %g seconds", time);
+      } catch (GLib.Error e) {
+#if DEBUG
+        GLib.message ("ERROR: "+e.message);
+#endif
+        assert_not_reached ();
+      }
+    });Test.add_func ("/gxml/performance/read/gdocument", 
+    () => {
+      try {
+        Test.timer_start ();
+        double time;
+        var d = new GDocument.from_path (GXmlTest.get_test_dir () + "/test-large.xml");
+        time = Test.timer_elapsed ();
+        Test.minimized_result (time, "Load large document: %g seconds", time);
+        Test.timer_start ();
+        iterate (d);
         time = Test.timer_elapsed ();
         Test.minimized_result (time, "Itirate over all loaded nodes: %g seconds", time);
       } catch (GLib.Error e) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]