[latexila] Structure: debug code for measuring parsing time
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Structure: debug code for measuring parsing time
- Date: Fri, 10 Jun 2011 19:43:41 +0000 (UTC)
commit 17032312dd370ab42c8294df7702ee72533fbae6
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Mon Jun 6 20:06:35 2011 +0200
Structure: debug code for measuring parsing time
src/document_structure.vala | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/document_structure.vala b/src/document_structure.vala
index 5ab1f02..2d8601e 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -36,6 +36,8 @@ public class DocumentStructure : GLib.Object
private static const int MAX_NB_LINES_TO_PARSE = 500;
private int _start_parsing_line = 0;
+ private bool _measure_parsing_time = true;
+
public DocumentStructure (TextBuffer doc)
{
_doc = doc;
@@ -77,6 +79,10 @@ public class DocumentStructure : GLib.Object
// Parse the document. Returns false if finished, true otherwise.
private bool parse_impl ()
{
+ Timer timer = null;
+ if (_measure_parsing_time)
+ timer = new Timer ();
+
/* search commands (begin with a backslash) */
// At the beginning of the search, the place where to insert new items is always
@@ -92,6 +98,10 @@ public class DocumentStructure : GLib.Object
int nb_lines = _doc.get_line_count ();
int end_parsing_line = _start_parsing_line + MAX_NB_LINES_TO_PARSE;
bool limit_parsing = nb_lines > end_parsing_line;
+
+ if (_measure_parsing_time)
+ limit_parsing = false;
+
if (limit_parsing)
_doc.get_iter_at_line (out limit, end_parsing_line);
@@ -124,6 +134,12 @@ public class DocumentStructure : GLib.Object
return true;
}
+ if (_measure_parsing_time)
+ {
+ timer.stop ();
+ stdout.printf ("Structure parsing took %f seconds\n", timer.elapsed ());
+ }
+
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]