stats: print thread key for stats and filter empty pad-sections

This commit is contained in:
Stefan Sauer 2013-11-17 11:37:14 +01:00
parent f8390caf2c
commit 81e617fa70

View file

@ -363,6 +363,14 @@ do_query_stats (GstStructure * s)
/* reporting */ /* 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 static void
print_pad_stats (gpointer value, gpointer user_data) print_pad_stats (gpointer value, gpointer user_data)
{ {
@ -404,7 +412,7 @@ print_pad_stats (gpointer value, gpointer user_data)
static void static void
print_thread_stats (gpointer key, gpointer value, gpointer user_data) print_thread_stats (gpointer key, gpointer value, gpointer user_data)
{ {
GSList *list = user_data; GSList *list = user_data, *node;
#if 0 #if 0
GstThreadStats *stats = (GstThreadStats *) value; GstThreadStats *stats = (GstThreadStats *) value;
guint cpuload = 0; 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); total = gst_util_uint64_scale (tusersys, G_GINT64_CONSTANT (100), last_ts);
cpuload = gst_util_uint64_scale (total, stats->treal, last_ts); cpuload = gst_util_uint64_scale (total, stats->treal, last_ts);
} }
#endif
printf ("Thread %p Statistics:\n", key); printf ("Thread %p Statistics:\n", key);
#if 0
printf (" Time: %" GST_TIME_FORMAT ", %u %%\n", GST_TIME_ARGS (stats->treal), printf (" Time: %" GST_TIME_FORMAT ", %u %%\n", GST_TIME_ARGS (stats->treal),
(guint) time_percent); (guint) time_percent);
printf (" Avg/Max CPU load: %u %%, %u %%\n", cpuload, stats->max_cpuload); printf (" Avg/Max CPU load: %u %%, %u %%\n", cpuload, stats->max_cpuload);
#endif #endif
/* FIXME: would be nice to skip, if there are no pads for that thread /* skip stats if there are no pads for that thread (e.g. a pipeline) */
* (e.g. a pipeline), we would need to pass as struct to if ((node = g_slist_find_custom (list, key, find_pad_stats_for_thread))) {
* g_hash_table_foreach::user_data puts (" Pad Statistics:");
*/ g_slist_foreach (node, print_pad_stats, key);
puts (" Pad Statistics:"); }
g_slist_foreach (list, print_pad_stats, key);
} }
static void static void