[sysprof/wip/visualizers] cpu-visualizer-row: stop after locating counters



commit 321fc18eee3f5310f484fb526c2a6e3cb9610f26
Author: Christian Hergert <chergert redhat com>
Date:   Mon Sep 26 22:14:44 2016 -0700

    cpu-visualizer-row: stop after locating counters
    
    In practice, we do a single counter definition for the CPU
    definitions. So we can stop iterating the samples after we
    successfully locate an item.

 lib/sp-cpu-visualizer-row.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/lib/sp-cpu-visualizer-row.c b/lib/sp-cpu-visualizer-row.c
index 62ac7ec..7a74639 100644
--- a/lib/sp-cpu-visualizer-row.c
+++ b/lib/sp-cpu-visualizer-row.c
@@ -35,19 +35,26 @@ sp_cpu_visualizer_counter_found (const SpCaptureFrame *frame,
 {
   const SpCaptureFrameCounterDefine *def = (SpCaptureFrameCounterDefine *)frame;
   GArray *counters = user_data;
+  gboolean found = FALSE;
 
   g_assert (frame->type == SP_CAPTURE_FRAME_CTRDEF);
 
+  /*
+   * In practice, all the CPU counters are defined at once, so we can avoid
+   * walking the rest of the capture by returning after we find our CTRDEF.
+   */
+
   for (guint i = 0; i < def->n_counters; i++)
     {
       if (g_str_equal (def->counters[i].category, "CPU Percent"))
         {
           guint id = def->counters[i].id;
           g_array_append_val (counters, id);
+          found = TRUE;
         }
     }
 
-  return TRUE;
+  return !found;
 }
 
 static void


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