[gxml] StreamReader: Added performance test



commit d82185bded33c442af2048d0f5d4f32c1aee1e9d
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon Jul 22 14:57:14 2019 -0500

    StreamReader: Added performance test

 test/DocumentPerformanceTest.vala     |  2 +-
 test/StreamReaderPerformanceTest.vala | 45 +++++++++++++++++++++++++++++++++++
 test/gxml-performance.vala            |  6 ++---
 test/meson.build                      | 12 ++++++++++
 4 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/test/DocumentPerformanceTest.vala b/test/DocumentPerformanceTest.vala
index e1d8a6f..b79613e 100644
--- a/test/DocumentPerformanceTest.vala
+++ b/test/DocumentPerformanceTest.vala
@@ -27,7 +27,7 @@ class GXmlTest.Suite : GLib.Object
   {
     GLib.Intl.setlocale (GLib.LocaleCategory.ALL, "");
     Test.init (ref args);
-    Test.add_func ("/gxml/gom-document/performance", () => {
+    Test.add_func ("/gxml/document/performance", () => {
     try {
       DomDocument d = new GXml.Document ();
       File dir = File.new_for_path (GXmlTestConfig.TEST_DIR);
diff --git a/test/StreamReaderPerformanceTest.vala b/test/StreamReaderPerformanceTest.vala
new file mode 100644
index 0000000..fe8eb11
--- /dev/null
+++ b/test/StreamReaderPerformanceTest.vala
@@ -0,0 +1,45 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/* GomDocumentPerformanceTest.vala
+ *
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *      Daniel Espinosa <esodan gmail com>
+ */
+
+using GXml;
+class GXmlTest.Suite : GLib.Object
+{
+  static int main (string[] args)
+  {
+    GLib.Intl.setlocale (GLib.LocaleCategory.ALL, "");
+    Test.init (ref args);
+    Test.add_func ("/gxml/stream-reader/performance", () => {
+    try {
+      File dir = File.new_for_path (GXmlTestConfig.TEST_DIR);
+      assert (dir.query_exists ());
+      File f = File.new_for_uri (dir.get_uri ()+"/test-large.xml");
+      assert (f.query_exists ());
+      var sr = new GXml.StreamReader (f.read ());
+      sr.read ();
+    } catch (GLib.Error e) {
+      warning ("Error: %s", e.message);
+      assert_not_reached ();
+    }
+  });
+  return Test.run ();
+}
+}
diff --git a/test/gxml-performance.vala b/test/gxml-performance.vala
index da620de..6b06ab4 100644
--- a/test/gxml-performance.vala
+++ b/test/gxml-performance.vala
@@ -50,12 +50,12 @@ public class Performance
   }
   public static void add_tests ()
   {
-    Test.add_func ("/gxml/performance/read/gomdocument",
+    Test.add_func ("/gxml/performance/read/document",
     () => {
       try {
         Test.timer_start ();
         double time;
-        var d = new GomDocument.from_path (GXmlTestConfig.TEST_DIR + "/test-large.xml");
+        var d = new Document.from_path (GXmlTestConfig.TEST_DIR + "/test-large.xml");
         time = Test.timer_elapsed ();
         Test.minimized_result (time, "Load large document: %g seconds", time);
         Test.timer_start ();
@@ -87,7 +87,7 @@ public class Performance
         assert_not_reached ();
       }
     });
-    Test.add_func ("/gxml/performance/se-deserialize/gomdocument",
+    Test.add_func ("/gxml/performance/se-deserialize/document",
     () => {
       try {
         double time;
diff --git a/test/meson.build b/test/meson.build
index baeb084..93dd014 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -103,4 +103,16 @@ libxml_performance_iterate = executable('libxml-performance-iterate', files_gom_
 )
 
 benchmark ('libxml-performance-iterate', libxml_performance_iterate)
+
+files_stream_reader_performance_iterate = files ([
+               'StreamReaderPerformanceTest.vala'
+       ])
+
+stream_reader_performance_iterate = executable('stream-reader-performance-load', 
files_stream_reader_performance_iterate + configvapi + configtestvapi,
+       vala_args : [],
+       dependencies : [ libgxml_deps, inc_libh_dep, testdirs_dep, inc_rooth_dep],
+       link_with: libgxml
+)
+
+benchmark ('stream-reader-performance-load', stream_reader_performance_iterate)
                


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