mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-09 22:50:54 +00:00
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.
This commit is contained in:
@ -35,19 +35,26 @@ sp_cpu_visualizer_counter_found (const SpCaptureFrame *frame,
|
|||||||
{
|
{
|
||||||
const SpCaptureFrameCounterDefine *def = (SpCaptureFrameCounterDefine *)frame;
|
const SpCaptureFrameCounterDefine *def = (SpCaptureFrameCounterDefine *)frame;
|
||||||
GArray *counters = user_data;
|
GArray *counters = user_data;
|
||||||
|
gboolean found = FALSE;
|
||||||
|
|
||||||
g_assert (frame->type == SP_CAPTURE_FRAME_CTRDEF);
|
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++)
|
for (guint i = 0; i < def->n_counters; i++)
|
||||||
{
|
{
|
||||||
if (g_str_equal (def->counters[i].category, "CPU Percent"))
|
if (g_str_equal (def->counters[i].category, "CPU Percent"))
|
||||||
{
|
{
|
||||||
guint id = def->counters[i].id;
|
guint id = def->counters[i].id;
|
||||||
g_array_append_val (counters, id);
|
g_array_append_val (counters, id);
|
||||||
|
found = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return !found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user