[gspell] InlineCheckerTextBuffer: add option to print performance debug info



commit b08dd9d9af25a27801871ac66a88ee397421b521
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Apr 1 19:37:52 2017 +0200

    InlineCheckerTextBuffer: add option to print performance debug info
    
    Can be useful if one day I want to improve the code to achieve 60 FPS
    (e.g. when GSK will be used to do 3D animations).

 gspell/gspell-inline-checker-text-buffer.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index 0bddc49..b7c2268 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -83,6 +83,8 @@ typedef enum
 #define TIMEOUT_DURATION_BUFFER_MODIFIED 16
 #define TIMEOUT_DURATION_DRAWING 20
 
+#define PERF_DEBUG FALSE
+
 G_DEFINE_TYPE (GspellInlineCheckerTextBuffer, _gspell_inline_checker_text_buffer, G_TYPE_OBJECT)
 
 /* Remove the highlight_tag only if present. If gtk_text_buffer_remove_tag() is
@@ -474,7 +476,25 @@ check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
                orig_start = start;
                orig_end = end;
 
-               check_subregion (spell, &start, &end);
+               {
+#if PERF_DEBUG
+                       GTimer *timer;
+
+                       g_print ("check_subregion [%d, %d]\n",
+                                gtk_text_iter_get_offset (&start),
+                                gtk_text_iter_get_offset (&end));
+
+                       timer = g_timer_new ();
+#endif
+
+                       check_subregion (spell, &start, &end);
+
+#if PERF_DEBUG
+                       g_print ("check_subregion took %lf ms.\n\n",
+                                1000 * g_timer_elapsed (timer, NULL));
+                       g_timer_destroy (timer);
+#endif
+               }
 
                /* Ensure that we don't have an infinite loop. We must subtract
                 * from scan_region at least [start, end], otherwise we will


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