From 81e617fa70d5dd43ad98ef833391129136e525f3 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Sun, 17 Nov 2013 11:37:14 +0100 Subject: [PATCH] stats: print thread key for stats and filter empty pad-sections --- tools/gst-stats.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/gst-stats.c b/tools/gst-stats.c index c7c550e20a..8c03eca62e 100644 --- a/tools/gst-stats.c +++ b/tools/gst-stats.c @@ -363,6 +363,14 @@ do_query_stats (GstStructure * s) /* reporting */ +static gint +find_pad_stats_for_thread (gconstpointer value, gconstpointer user_data) +{ + const GstPadStats *stats = (const GstPadStats *) value; + + return (stats->thread_id == GPOINTER_TO_UINT (user_data)) ? 0 : 1; +} + static void print_pad_stats (gpointer value, gpointer user_data) { @@ -404,7 +412,7 @@ print_pad_stats (gpointer value, gpointer user_data) static void print_thread_stats (gpointer key, gpointer value, gpointer user_data) { - GSList *list = user_data; + GSList *list = user_data, *node; #if 0 GstThreadStats *stats = (GstThreadStats *) value; guint cpuload = 0; @@ -422,18 +430,19 @@ print_thread_stats (gpointer key, gpointer value, gpointer user_data) total = gst_util_uint64_scale (tusersys, G_GINT64_CONSTANT (100), last_ts); cpuload = gst_util_uint64_scale (total, stats->treal, last_ts); } +#endif printf ("Thread %p Statistics:\n", key); +#if 0 printf (" Time: %" GST_TIME_FORMAT ", %u %%\n", GST_TIME_ARGS (stats->treal), (guint) time_percent); printf (" Avg/Max CPU load: %u %%, %u %%\n", cpuload, stats->max_cpuload); #endif - /* FIXME: would be nice to skip, if there are no pads for that thread - * (e.g. a pipeline), we would need to pass as struct to - * g_hash_table_foreach::user_data - */ - puts (" Pad Statistics:"); - g_slist_foreach (list, print_pad_stats, key); + /* skip stats if there are no pads for that thread (e.g. a pipeline) */ + if ((node = g_slist_find_custom (list, key, find_pad_stats_for_thread))) { + puts (" Pad Statistics:"); + g_slist_foreach (node, print_pad_stats, key); + } } static void