libsysprof-ui: add more capture details

This commit is contained in:
Christian Hergert
2019-05-15 16:39:02 -07:00
parent aed80ea51f
commit e03b1ec8b7
3 changed files with 146 additions and 34 deletions

View File

@ -221,6 +221,7 @@ sysprof_capture_view_scan_worker (GTask *task,
SysprofCaptureReader *reader = task_data;
SysprofCaptureFeatures features = {0};
SysprofCaptureFrame frame;
SysprofCaptureStat st_buf = {0};
g_assert (SYSPROF_IS_CAPTURE_VIEW (self));
g_assert (G_IS_TASK (task));
@ -235,6 +236,10 @@ sysprof_capture_view_scan_worker (GTask *task,
gint64 begin_time = frame.time;
gint64 end_time = G_MININT64;
g_assert (frame.type < G_N_ELEMENTS (st_buf.frame_count));
st_buf.frame_count[frame.type]++;
if (frame.type == SYSPROF_CAPTURE_FRAME_MARK)
{
const SysprofCaptureMark *mark;
@ -265,6 +270,8 @@ sysprof_capture_view_scan_worker (GTask *task,
features.end_time = end_time;
}
sysprof_capture_reader_set_stat (reader, &st_buf);
if (!g_task_return_error_if_cancelled (task))
{
priv->features = features;
@ -428,6 +435,8 @@ sysprof_capture_view_load_scan_cb (GObject *object,
g_object_ref (task));
}
sysprof_details_view_set_reader (priv->details_view, priv->reader);
if (state->n_active == 0)
g_task_return_boolean (task, TRUE);
}
@ -488,8 +497,6 @@ sysprof_capture_view_real_load_async (SysprofCaptureView *self,
cancellable,
sysprof_capture_view_load_scan_cb,
g_steal_pointer (&task));
sysprof_details_view_set_reader (priv->details_view, reader);
}
static gboolean

View File

@ -26,10 +26,17 @@
#include "sysprof-details-view.h"
#define NSEC_PER_SEC (G_USEC_PER_SEC * 1000L)
struct _SysprofDetailsView
{
GtkBin parent_instance;
GtkLabel *duration;
GtkLabel *filename;
GtkLabel *forks;
GtkLabel *marks;
GtkLabel *processes;
GtkLabel *samples;
GtkLabel *start_time;
};
@ -50,7 +57,12 @@ sysprof_details_view_class_init (SysprofDetailsViewClass *klass)
object_class->finalize = sysprof_details_view_finalize;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-details-view.ui");
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, duration);
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, filename);
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, forks);
gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, marks);
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);
}
@ -72,10 +84,14 @@ sysprof_details_view_set_reader (SysprofDetailsView *self,
{
g_autoptr(GDateTime) dt = NULL;
g_autoptr(GDateTime) local = NULL;
g_autofree gchar *duration_str = NULL;
const gchar *filename;
const gchar *capture_at;
SysprofCaptureStat st_buf;
gint64 duration;
g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self));
g_return_if_fail (reader != NULL);
if (!(filename = sysprof_capture_reader_get_filename (reader)))
filename = _("Memory Capture");
@ -88,4 +104,26 @@ sysprof_details_view_set_reader (SysprofDetailsView *self,
g_autofree gchar *str = g_date_time_format (local, "%x %X");
gtk_label_set_label (self->start_time, str);
}
duration = sysprof_capture_reader_get_end_time (reader) -
sysprof_capture_reader_get_start_time (reader);
duration_str = g_strdup_printf (_("%0.4lf seconds"), duration / (gdouble)NSEC_PER_SEC);
gtk_label_set_label (self->duration, duration_str);
if (sysprof_capture_reader_get_stat (reader, &st_buf))
{
#define SET_FRAME_COUNT(field, TYPE) \
G_STMT_START { \
g_autofree gchar *str = NULL; \
str = g_strdup_printf ("%"G_GSIZE_FORMAT, st_buf.frame_count[TYPE]); \
gtk_label_set_label (self->field, str); \
} G_STMT_END
SET_FRAME_COUNT (samples, SYSPROF_CAPTURE_FRAME_SAMPLE);
SET_FRAME_COUNT (marks, SYSPROF_CAPTURE_FRAME_MARK);
SET_FRAME_COUNT (processes, SYSPROF_CAPTURE_FRAME_PROCESS);
SET_FRAME_COUNT (forks, SYSPROF_CAPTURE_FRAME_FORK);
#undef SET_FRAME_COUNT
}
}

View File

@ -32,11 +32,6 @@
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
@ -48,17 +43,69 @@
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</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="expand">True</property>
<property name="fill">True</property>
<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">
@ -74,11 +121,6 @@
<property name="ellipsize">start</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="start_time">
@ -87,25 +129,50 @@
<property name="ellipsize">start</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</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>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>