mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: add some mark details
This commit is contained in:
@ -22,6 +22,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "sysprof-callgraph-view.h"
|
||||
#include "sysprof-capture-view.h"
|
||||
#include "sysprof-details-view.h"
|
||||
@ -29,6 +31,8 @@
|
||||
#include "sysprof-ui-private.h"
|
||||
#include "sysprof-visualizer-view.h"
|
||||
|
||||
#define NSEC_PER_SEC (G_USEC_PER_SEC * 1000L)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint64 begin_time;
|
||||
@ -42,6 +46,7 @@ typedef struct
|
||||
{
|
||||
SysprofCaptureReader *reader;
|
||||
GCancellable *cancellable;
|
||||
GHashTable *mark_stats;
|
||||
|
||||
SysprofCaptureFeatures features;
|
||||
|
||||
@ -122,6 +127,62 @@ sysprof_capture_view_new (void)
|
||||
return g_object_new (SYSPROF_TYPE_CAPTURE_VIEW, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
add_marks_to_details (SysprofCaptureView *self)
|
||||
{
|
||||
SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self);
|
||||
GHashTableIter iter;
|
||||
gpointer k, v;
|
||||
guint count = 0;
|
||||
|
||||
g_assert (SYSPROF_IS_CAPTURE_VIEW (self));
|
||||
|
||||
if (priv->mark_stats == NULL)
|
||||
return;
|
||||
|
||||
if (g_hash_table_size (priv->mark_stats) == 0)
|
||||
return;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->mark_stats);
|
||||
while (count < 100 && g_hash_table_iter_next (&iter, &k, &v))
|
||||
{
|
||||
g_autofree gchar *str = NULL;
|
||||
SysprofMarkStat *st = v;
|
||||
GtkLabel *left_label;
|
||||
GtkLabel *center_label;
|
||||
|
||||
if (st->avg == 0)
|
||||
continue;
|
||||
|
||||
left_label = g_object_new (GTK_TYPE_LABEL,
|
||||
"visible", TRUE,
|
||||
"xalign", 1.0f,
|
||||
"label", st->name,
|
||||
"ellipsize", PANGO_ELLIPSIZE_START,
|
||||
NULL);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (left_label)),
|
||||
GTK_STYLE_CLASS_DIM_LABEL);
|
||||
str = g_strdup_printf ("<span fgalpha='32767'>Min:</span> %.4lf "
|
||||
"<span fgalpha='32767'>Max:</span> %.4lf "
|
||||
"<span fgalpha='32767'>Ø:</span> %.4lf",
|
||||
st->min / (gdouble)NSEC_PER_SEC,
|
||||
st->max / (gdouble)NSEC_PER_SEC,
|
||||
st->avg / (gdouble)NSEC_PER_SEC);
|
||||
center_label = g_object_new (GTK_TYPE_LABEL,
|
||||
"label", str,
|
||||
"use-markup", TRUE,
|
||||
"visible", TRUE,
|
||||
"xalign", 0.0f,
|
||||
NULL);
|
||||
|
||||
sysprof_details_view_add_item (priv->details_view,
|
||||
GTK_WIDGET (left_label),
|
||||
GTK_WIDGET (center_label));
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_capture_view_task_completed (SysprofCaptureView *self,
|
||||
GParamSpec *pspec,
|
||||
@ -348,6 +409,11 @@ sysprof_capture_view_scan_worker (GTask *task,
|
||||
|
||||
sysprof_capture_reader_set_stat (reader, &st_buf);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (task),
|
||||
"MARK_STAT",
|
||||
g_steal_pointer (&mark_stats),
|
||||
(GDestroyNotify) g_hash_table_unref);
|
||||
|
||||
if (!g_task_return_error_if_cancelled (task))
|
||||
{
|
||||
priv->features = features;
|
||||
@ -384,6 +450,7 @@ sysprof_capture_view_scan_finish (SysprofCaptureView *self,
|
||||
GError **error)
|
||||
{
|
||||
SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self);
|
||||
GHashTable *stats;
|
||||
|
||||
g_assert (SYSPROF_IS_CAPTURE_VIEW (self));
|
||||
g_assert (G_IS_TASK (result));
|
||||
@ -391,6 +458,12 @@ sysprof_capture_view_scan_finish (SysprofCaptureView *self,
|
||||
if (!priv->features.has_samples && priv->features.has_marks)
|
||||
gtk_stack_set_visible_child_name (priv->stack, "timings");
|
||||
|
||||
g_clear_pointer (&priv->mark_stats, g_hash_table_unref);
|
||||
if ((stats = g_object_get_data (G_OBJECT (result), "MARK_STAT")))
|
||||
priv->mark_stats = g_hash_table_ref (stats);
|
||||
|
||||
add_marks_to_details (self);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
@ -671,6 +744,7 @@ sysprof_capture_view_finalize (GObject *object)
|
||||
SysprofCaptureView *self = (SysprofCaptureView *)object;
|
||||
SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self);
|
||||
|
||||
g_clear_pointer (&priv->mark_stats, g_hash_table_unref);
|
||||
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
|
||||
g_clear_object (&priv->cancellable);
|
||||
|
||||
|
||||
@ -31,6 +31,10 @@
|
||||
struct _SysprofDetailsView
|
||||
{
|
||||
GtkBin parent_instance;
|
||||
|
||||
/* Template Objects */
|
||||
GtkBox *left_box;
|
||||
GtkBox *center_box;
|
||||
GtkLabel *duration;
|
||||
GtkLabel *filename;
|
||||
GtkLabel *forks;
|
||||
@ -38,6 +42,7 @@ struct _SysprofDetailsView
|
||||
GtkLabel *processes;
|
||||
GtkLabel *samples;
|
||||
GtkLabel *start_time;
|
||||
GtkBox *vbox;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (SysprofDetailsView, sysprof_details_view, GTK_TYPE_BIN)
|
||||
@ -87,6 +92,9 @@ sysprof_details_view_class_init (SysprofDetailsViewClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, processes);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, samples);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, start_time);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, vbox);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, left_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, center_box);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -150,3 +158,20 @@ sysprof_details_view_set_reader (SysprofDetailsView *self,
|
||||
#undef SET_FRAME_COUNT
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_details_view_add_item (SysprofDetailsView *self,
|
||||
GtkWidget *left,
|
||||
GtkWidget *center)
|
||||
{
|
||||
g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self));
|
||||
g_return_if_fail (GTK_IS_WIDGET (left));
|
||||
g_return_if_fail (GTK_IS_WIDGET (center));
|
||||
|
||||
gtk_container_add_with_properties (GTK_CONTAINER (self->left_box), left,
|
||||
"pack-type", GTK_PACK_START,
|
||||
"expand", TRUE,
|
||||
"fill", TRUE,
|
||||
NULL);
|
||||
gtk_container_add (GTK_CONTAINER (self->center_box), center);
|
||||
}
|
||||
|
||||
@ -32,5 +32,8 @@ G_DECLARE_FINAL_TYPE (SysprofDetailsView, sysprof_details_view, SYSPROF, DETAILS
|
||||
GtkWidget *sysprof_details_view_new (void);
|
||||
void sysprof_details_view_set_reader (SysprofDetailsView *self,
|
||||
SysprofCaptureReader *reader);
|
||||
void sysprof_details_view_add_item (SysprofDetailsView *self,
|
||||
GtkWidget *left,
|
||||
GtkWidget *center);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -142,7 +142,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="SysprofDetailsView" id="details_view">
|
||||
<property name="margin">36</property>
|
||||
<property name="visible">true</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
||||
@ -5,169 +5,178 @@
|
||||
<template class="SysprofDetailsView" parent="GtkBin">
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="propagate-natural-height">true</property>
|
||||
<property name="visible">true</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<object class="GtkBox" id="vbox">
|
||||
<property name="margin">36</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="spacing">12</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<object class="GtkBox" id="left_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Filename</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
<property name="halign">end</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Filename</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Captured At</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Duration</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="margin-top">12</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Samples Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Marks Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Processes Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="label" translatable="yes">Forks Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
<property name="position">0</property>
|
||||
<property name="expand">true</property>
|
||||
<property name="fill">true</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<child type="center">
|
||||
<object class="GtkBox" id="center_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Captured At</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Duration</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="margin-top">12</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Samples Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Marks Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Processes Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Forks Captured</property>
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
<property name="position">0</property>
|
||||
<property name="expand">true</property>
|
||||
<property name="fill">true</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="center">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="filename">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="start_time">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="duration">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="samples">
|
||||
<property name="margin-top">12</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="marks">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="processes">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="forks">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="filename">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="start_time">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="duration">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="samples">
|
||||
<property name="margin-top">12</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="marks">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="processes">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="forks">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user