[tracker-miners/wip/carlosg/stats-logging: 1/3] libtracker-miner: Ensure timer is started when processing elements




commit 53d6376363f8c073c2029803b19df3ee22e2b708
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Aug 6 17:01:34 2022 +0200

    libtracker-miner: Ensure timer is started when processing elements
    
    Currently, the GTimer used to log the time spent processing is used
    in a broken manner. It is only started once when the miner is started,
    and every later batch of processing (e.g. monitor events) just stops
    the timer and prints the elapsed time, which simply extends the elapsed
    time based on the fixed start time, and info logging about our elapsed
    time are forever based on the moment the miner was started.
    
    Since the places where the timer is started currently don't apply to
    monitor events after the miner is running, ensure the timer is started
    when events do arrive in a state of idleness.
    
    This ensures our elapsed time always reports the time spent in processing
    the batch of events, until the miner becomes idle again.

 src/libtracker-miner/tracker-miner-fs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index f56a26495..048a31554 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1270,6 +1270,11 @@ miner_handle_next_item (TrackerMinerFS *fs)
        item_queue_get_next_file (fs, &file, &source_file, &info, &type,
                                  &attributes_update, &is_dir);
 
+       if (fs->priv->timer_stopped) {
+               g_timer_start (fs->priv->timer);
+               fs->priv->timer_stopped = FALSE;
+       }
+
        if (file == NULL && !fs->priv->extraction_timer_stopped) {
                g_timer_stop (fs->priv->extraction_timer);
                fs->priv->extraction_timer_stopped = TRUE;
@@ -1679,11 +1684,6 @@ file_notifier_directory_started (TrackerFileNotifier *notifier,
                 str = g_strdup_printf ("Crawling single directory '%s'", uri);
         }
 
-       if (fs->priv->timer_stopped) {
-               g_timer_start (fs->priv->timer);
-               fs->priv->timer_stopped = FALSE;
-       }
-
        /* Always set the progress here to at least 1%, and the remaining time
          * to -1 as we cannot guess during crawling (we don't know how many directories
          * we will find) */


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