[gxml] Added more performance tests using GDocument to de/serialize
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Added more performance tests using GDocument to de/serialize
- Date: Thu, 25 Feb 2016 00:20:49 +0000 (UTC)
commit 2b4d6f0640a8023a6fe3666d5df9ab8487097dfe
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Feb 24 18:17:43 2016 -0600
Added more performance tests using GDocument to de/serialize
* GDocument used for tests to check performance on deserialize
showing a 50% less time on initial load and 10% on post-deserialize
gxml/GXmlElement.vala | 1 -
gxml/GXmlHashMapAttr.vala | 1 -
gxml/Node.vala | 4 -
test/gxml-performance.vala | 203 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 203 insertions(+), 6 deletions(-)
---
diff --git a/gxml/GXmlElement.vala b/gxml/GXmlElement.vala
index 698f7a0..33aa96d 100644
--- a/gxml/GXmlElement.vala
+++ b/gxml/GXmlElement.vala
@@ -57,7 +57,6 @@ public class GXml.GElement : GXml.GNode, GXml.Element
n = pp[1];
}
var ps = _node->properties;
- Test.message ("Name= "+n+" Prefix= "+prefix);
while (ps != null) {
if (ps->name == n) {
if (ps->ns == null && prefix == "") return new GAttribute (_doc, ps);
diff --git a/gxml/GXmlHashMapAttr.vala b/gxml/GXmlHashMapAttr.vala
index f51891e..54b3cf4 100644
--- a/gxml/GXmlHashMapAttr.vala
+++ b/gxml/GXmlHashMapAttr.vala
@@ -65,7 +65,6 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>
var prefix = pp[0];
var n = pp[1];
while (ps != null) {
- Test.message ("At Attribute: "+ps->name);
if (ps->name == n) {
if (ps->ns == null) continue;
if (ps->ns->prefix == prefix)
diff --git a/gxml/Node.vala b/gxml/Node.vala
index 52119d2..35ade37 100644
--- a/gxml/Node.vala
+++ b/gxml/Node.vala
@@ -90,14 +90,10 @@ public interface GXml.Node : Object
if (!(this is GXml.Element)) return list;
foreach (var child in children) {
if (child is GXml.Element) {
- Test.message ("At node: "+child.name);
list.add_all (child.get_elements_by_property_value (property, value));
- Test.message ("Node is Element: "+child.name);
if (child.attrs == null) continue;
- Test.message ("Searching property: "+property+" in node: "+child.name);
var cls = child.attrs.get (property);
if (cls == null) {
- Test.message ("No property :"+ property+" found");
continue;
}
if (value in cls.value)
diff --git a/test/gxml-performance.vala b/test/gxml-performance.vala
index d958e7c..811146f 100644
--- a/test/gxml-performance.vala
+++ b/test/gxml-performance.vala
@@ -689,6 +689,209 @@ public class Performance
assert_not_reached ();
}
});
+ Test.add_func ("/gxml/performance/gdocument/hashmap/post-deserialization/disable",
+ () => {
+ try {
+ var f = GLib.File.new_for_path
(GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ if (f.query_exists ()) f.delete ();
+ double time;
+ Test.message ("Starting generating document...");
+ Test.timer_start ();
+ var d = new GDocument ();
+ var ce = new HTopElement ();
+ for (int i = 0; i < 30000; i++) {
+ var e1 = new HElement ();
+ e1.name = "1E"+i.to_string ();
+ ce.elements1.elements.set (e1.name, e1);
+ var e2 = new HElement ();
+ e2.name = "2E"+i.to_string ();
+ ce.elements2.elements.set (e2.name, e2);
+ }
+ assert (ce.elements1.elements.size == 30000);
+ assert (ce.elements2.elements.size == 30000);
+ ce.serialize (d);
+ d.save_as (f);
+ assert (d.root != null);
+ assert (d.root.children.size == 2);
+ assert (d.root.children[0].children.size == 30000);
+ assert (d.root.children[1].children.size == 30000);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Created document: %g seconds", time);
+ Test.message ("Starting deserializing document: Disable collection deserialization...");
+ Test.timer_start ();
+ var gd = new GDocument.from_path (GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Opening doc: %g seconds", time);
+ Test.message ("Start deseralization of GDocument");
+ Test.timer_start ();
+ var cep = new HTopElement ();
+ cep.elements1.elements.enable_deserialize = false;
+ cep.elements2.elements.enable_deserialize = false;
+ cep.deserialize (gd);
+ assert(cep.elements1.elements.size == 0);
+ assert(cep.elements2.elements.size == 0);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "GDocument Disable Deserialize Collection. Deserialized from doc: %g
seconds", time);
+ Test.message ("Calling C1 deserialize_children()...");
+ Test.timer_start ();
+ assert (cep.elements1.elements.deserialize_children ());
+ assert (cep.elements1.elements.size == 30000);
+ assert (!cep.elements1.elements.deserialize_children ());
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "C1: Disable Deserialize Collection. Deserialized from NODE: %g
seconds", time);
+ Test.message ("Calling C2 deserialize_children()...");
+ Test.timer_start ();
+ cep.elements2.elements.deserialize_children ();
+ assert (!cep.elements2.elements.deserialize_children ());
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "C2: Disable Deserialize Collection. Deserialized from NODE: %g
seconds", time);
+ } catch (GLib.Error e) {
+ GLib.message ("ERROR: "+e.message);
+ assert_not_reached ();
+ }
+ });
+ Test.add_func ("/gxml/performance/gdocument/hashmap/post-deserialization/enable",
+ () => {
+ try {
+ var f = GLib.File.new_for_path
(GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ if (f.query_exists ()) f.delete ();
+ double time;
+ Test.message ("Starting generating document...");
+ Test.timer_start ();
+ var d = new GDocument ();
+ var ce = new HTopElement ();
+ for (int i = 0; i < 30000; i++) {
+ var e1 = new HElement ();
+ e1.name = "1E"+i.to_string ();
+ ce.elements1.elements.set (e1.name, e1);
+ var e2 = new HElement ();
+ e2.name = "2E"+i.to_string ();
+ ce.elements2.elements.set (e2.name, e2);
+ }
+ assert (ce.elements1.elements.size == 30000);
+ assert (ce.elements2.elements.size == 30000);
+ ce.serialize (d);
+ d.save_as (f);
+ assert (d.root != null);
+ assert (d.root.children.size == 2);
+ assert (d.root.children[0].children.size == 30000);
+ assert (d.root.children[1].children.size == 30000);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Created document: %g seconds", time);
+ Test.message ("Starting deserializing document: Enable collection deserialization...");
+ Test.timer_start ();
+ var gd = new GDocument.from_path (GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Opening doc: %g seconds", time);
+ Test.message ("Start deseralization of GDocument");
+ Test.timer_start ();
+ var cep = new HTopElement ();
+ cep.elements1.elements.enable_deserialize = true;
+ cep.elements2.elements.enable_deserialize = true;
+ cep.deserialize (gd);
+ assert(cep.elements1.elements.size == 30000);
+ assert(cep.elements2.elements.size == 30000);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "GDocument Enable Deserialize Collection. Deserialized from doc: %g
seconds", time);
+ Test.message ("Calling C1 deserialize_children()...");
+ Test.timer_start ();
+ assert (cep.elements1.elements.size == 30000);
+ assert (!cep.elements1.elements.deserialize_children ());
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "C1: Enable Deserialize Collection. Deserialized from NODE: %g
seconds", time);
+ Test.message ("Calling C2 deserialize_children()...");
+ Test.timer_start ();
+ assert (!cep.elements2.elements.deserialize_children ());
+ assert (!cep.elements2.elements.deserialize_children ());
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "C2: Disable Deserialize Collection. Deserialized from NODE: %g
seconds", time);
+ } catch (GLib.Error e) {
+ GLib.message ("ERROR: "+e.message);
+ assert_not_reached ();
+ }
+ });
+ Test.add_func ("/gxml/performance/gdocument/arraylist/post-deserialization/disable",
+ () => {
+ try {
+ var f = GLib.File.new_for_path
(GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ if (f.query_exists ()) f.delete ();
+ double time;
+ Test.message ("Starting generating document...");
+ Test.timer_start ();
+ var d = new GDocument ();
+ var ce = new CElement ();
+ for (int i = 0; i < 30000; i++) {
+ var e = new AElement ();
+ ce.elements.add (e);
+ }
+ ce.serialize (d);
+ d.save_as (f);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Created document: %g seconds", time);
+ Test.message ("Starting deserializing document: Disable collection deserialization...");
+ Test.timer_start ();
+ var gd = new GDocument.from_path (GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Opening doc: %g seconds", time);
+ Test.message ("Start deseralization of GDocument");
+ Test.timer_start ();
+ var cep = new CElement ();
+ cep.elements.enable_deserialize = false;
+ cep.deserialize (gd);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Disable Deserialize Collection. Deserialized from doc: %g seconds",
time);
+ Test.message ("Calling deserialize_children()...");
+ Test.timer_start ();
+ cep.elements.deserialize_children ();
+ assert (!cep.elements.deserialize_children ());
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Disable Deserialize Collection. Deserialized from NODE: %g seconds",
time);
+ } catch (GLib.Error e) {
+ GLib.message ("ERROR: "+e.message);
+ assert_not_reached ();
+ }
+ });
+ Test.add_func ("/gxml/performance/gdocument/arraylist/post-deserialization/enable",
+ () => {
+ try {
+ var f = GLib.File.new_for_path
(GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ if (f.query_exists ()) f.delete ();
+ double time;
+ Test.message ("Starting generating document...");
+ Test.timer_start ();
+ var d = new GDocument ();
+ var ce = new CElement ();
+ for (int i = 0; i < 30000; i++) {
+ var e = new AElement ();
+ ce.elements.add (e);
+ }
+ ce.serialize (d);
+ d.save_as (f);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Created document: %g seconds", time);
+ Test.message ("Starting deserializing document: Disable collection deserialization...");
+ Test.timer_start ();
+ var gd = new GDocument.from_path (GXmlTestConfig.TEST_SAVE_DIR+"/post-des-test-file.xml");
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Opening doc: %g seconds", time);
+ Test.message ("Start deseralization of GDocument");
+ Test.timer_start ();
+ var cep = new CElement ();
+ cep.elements.enable_deserialize = true;
+ cep.deserialize (gd);
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Enable Deserialize Collection. Deserialized from doc: %g seconds",
time);
+ Test.message ("Calling deserialize_children()...");
+ Test.timer_start ();
+ cep.elements.deserialize_children ();
+ assert (!cep.elements.deserialize_children ());
+ time = Test.timer_elapsed ();
+ Test.minimized_result (time, "Enable Deserialize Collection. Deserialized from NODE: %g seconds",
time);
+ } catch (GLib.Error e) {
+ GLib.message ("ERROR: "+e.message);
+ assert_not_reached ();
+ }
+ });
#endif
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]