[gedit/wip/spell-checking: 3/3] auto-spell: add check_region() timing debug information



commit 0af15f38dd7ec72b872ead7b594b135ca7928d8a
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue Jul 21 10:24:20 2015 +0200

    auto-spell: add check_region() timing debug information

 plugins/spell/gedit-automatic-spell-checker.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/plugins/spell/gedit-automatic-spell-checker.c b/plugins/spell/gedit-automatic-spell-checker.c
index 9243596..f1f5fc6 100644
--- a/plugins/spell/gedit-automatic-spell-checker.c
+++ b/plugins/spell/gedit-automatic-spell-checker.c
@@ -55,6 +55,8 @@ enum
        PROP_SPELL_CHECKER,
 };
 
+#define ENABLE_DEBUG 0
+
 #define AUTOMATIC_SPELL_CHECKER_KEY    "GeditAutomaticSpellCheckerID"
 #define SUGGESTION_KEY                 "GeditAutoSuggestionID"
 
@@ -175,12 +177,19 @@ static void
 check_region (GeditAutomaticSpellChecker *spell)
 {
        GtkTextRegionIterator region_iter;
+#if ENABLE_DEBUG
+       GTimer *timer;
+#endif
 
        if (spell->scan_region == NULL)
        {
                return;
        }
 
+#if ENABLE_DEBUG
+       timer = g_timer_new ();
+#endif
+
        gtk_text_region_get_iterator (spell->scan_region, &region_iter, 0);
 
        while (!gtk_text_region_iterator_is_end (&region_iter))
@@ -197,6 +206,14 @@ check_region (GeditAutomaticSpellChecker *spell)
 
        gtk_text_region_destroy (spell->scan_region);
        spell->scan_region = NULL;
+
+#if ENABLE_DEBUG
+       g_print ("%s() executed in %lf seconds\n",
+                G_STRFUNC,
+                g_timer_elapsed (timer, NULL));
+
+       g_timer_destroy (timer);
+#endif
 }
 
 static gboolean


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