[gxml] StreamReader: setup test for async buffer parsing



commit a65770dfee700c51eb5aa10b1c712a648444965d
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue Jul 30 12:28:33 2019 -0500

    StreamReader: setup test for async buffer parsing

 ...reamReaderPerformanceAsyncReadUnparsedTest.vala | 75 ++++++++++++++++++++++
 ...amReaderPerformanceIterateReadUnparsedTest.vala |  2 +-
 test/meson.build                                   | 19 +++++-
 3 files changed, 92 insertions(+), 4 deletions(-)
---
diff --git a/test/StreamReaderPerformanceAsyncReadUnparsedTest.vala 
b/test/StreamReaderPerformanceAsyncReadUnparsedTest.vala
new file mode 100644
index 0000000..c84e2ad
--- /dev/null
+++ b/test/StreamReaderPerformanceAsyncReadUnparsedTest.vala
@@ -0,0 +1,75 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/* StreamReaderPerformanceAsyncReadUnparsedTest.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", () => {
+      var loop = new MainLoop (null);
+      var timer = new Timer ();
+      ulong time = 0;
+      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 ());
+        var d = sr.read ();
+        timer.elapsed (out time);
+        message ("Initial Parse: %lu ms for %d nodes", time / 1000, d.document_element.child_nodes.length);
+        Timeout.add_full (0, 10, ()=>{
+          int l = d.document_element.child_nodes.item (5000).child_nodes.length;
+          if (l == 0) {
+            return Source.CONTINUE;
+          }
+          try {
+            message ((d.document_element.child_nodes.item (5000) as DomElement).write_string ());
+          } catch (GLib.Error e) {
+            warning ("Error: %s", e.message);
+          }
+          loop.quit ();
+          return Source.REMOVE;
+        });
+        Idle.add (()=>{
+            (d.document_element as GXml.Element).parse_buffer_async.begin ((obj, res)=>{
+              try {
+                (d.document_element as GXml.Element).parse_buffer_async.end (res);
+              } catch (GLib.Error e) {
+                warning ("Error: %s", e.message);
+              }
+              timer.elapsed (out time);
+              message ("Parse root: %lu ms", time / 1000);
+            });
+          return Source.REMOVE;
+        });
+      } catch (GLib.Error e) {
+        warning ("Error: %s", e.message);
+      }
+      loop.run ();
+    });
+    return Test.run ();
+  }
+}
diff --git a/test/StreamReaderPerformanceIterateReadUnparsedTest.vala 
b/test/StreamReaderPerformanceIterateReadUnparsedTest.vala
index 6c8a81a..299afb2 100644
--- a/test/StreamReaderPerformanceIterateReadUnparsedTest.vala
+++ b/test/StreamReaderPerformanceIterateReadUnparsedTest.vala
@@ -1,5 +1,5 @@
 /* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
-/* GomDocumentPerformanceTest.vala
+/* StreamReaderPerformanceAsyncReadUnparsedTest.vala
  *
  * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
  *
diff --git a/test/meson.build b/test/meson.build
index c2f875c..b0dc80a 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -130,15 +130,28 @@ stream_reader_performance_iterate = executable('stream-reader-performance-iterat
 benchmark ('stream-reader-performance-iterate', stream_reader_performance_iterate)
 
 
-files_stream_reader_performance_iterate_read = files ([
+files_stream_reader_performance_unparsed = files ([
                'StreamReaderPerformanceIterateReadUnparsedTest.vala'
        ])
 
-stream_reader_performance_iterate = executable('stream-reader-performance-unparsed', 
files_stream_reader_performance_iterate_read + configvapi + configtestvapi,
+stream_reader_performance_unparsed = executable('stream-reader-performance-unparsed', 
files_stream_reader_performance_unparsed + configvapi + configtestvapi,
        vala_args : [],
        dependencies : [ libgxml_deps, inc_libh_dep, testdirs_dep, inc_rooth_dep],
        link_with: libgxml
 )
 
-benchmark ('stream-reader-performance-unparsed', stream_reader_performance_iterate)
+benchmark ('stream-reader-performance-unparsed', stream_reader_performance_unparsed)
+
+
+files_stream_reader_performance_async_read = files ([
+               'StreamReaderPerformanceAsyncReadUnparsedTest.vala'
+       ])
+
+stream_reader_performance_async_read = executable('stream-reader-performance-async', 
files_stream_reader_performance_async_read + configvapi + configtestvapi,
+       vala_args : [],
+       dependencies : [ libgxml_deps, inc_libh_dep, testdirs_dep, inc_rooth_dep],
+       link_with: libgxml
+)
+
+benchmark ('stream-reader-performance-async', stream_reader_performance_async_read)
 


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