mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-gtk: create depth chart for samples
This commit is contained in:
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <adwaita.h>
|
#include <adwaita.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <sysprof-analyze.h>
|
#include <sysprof-analyze.h>
|
||||||
#include <sysprof-gtk.h>
|
#include <sysprof-gtk.h>
|
||||||
|
|
||||||
@ -39,11 +40,15 @@ main (int argc,
|
|||||||
g_autoptr(SysprofDocumentLoader) loader = NULL;
|
g_autoptr(SysprofDocumentLoader) loader = NULL;
|
||||||
g_autoptr(SysprofDocument) document = NULL;
|
g_autoptr(SysprofDocument) document = NULL;
|
||||||
g_autoptr(SysprofSession) session = NULL;
|
g_autoptr(SysprofSession) session = NULL;
|
||||||
|
g_autoptr(SysprofXYSeries) samples_series = NULL;
|
||||||
|
g_autoptr(GListModel) samples = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
const SysprofTimeSpan *time_span;
|
||||||
GtkWidget *chart;
|
GtkWidget *chart;
|
||||||
GtkWidget *layer;
|
GtkWidget *layer;
|
||||||
GtkWindow *window;
|
GtkWindow *window;
|
||||||
GtkWidget *box;
|
GtkWidget *box;
|
||||||
|
guint n_samples;
|
||||||
|
|
||||||
sysprof_clock_init ();
|
sysprof_clock_init ();
|
||||||
|
|
||||||
@ -74,6 +79,20 @@ main (int argc,
|
|||||||
g_error ("Failed to load document: %s", error->message);
|
g_error ("Failed to load document: %s", error->message);
|
||||||
|
|
||||||
session = sysprof_session_new (document);
|
session = sysprof_session_new (document);
|
||||||
|
time_span = sysprof_document_get_time_span (document);
|
||||||
|
|
||||||
|
/* Generate an XY Series using the stacktraces depth for Y */
|
||||||
|
samples = sysprof_document_list_samples (document);
|
||||||
|
n_samples = g_list_model_get_n_items (samples);
|
||||||
|
samples_series = sysprof_xy_series_new (samples, time_span->begin_nsec, 0, time_span->end_nsec, 128);
|
||||||
|
for (guint i = 0; i < n_samples; i++)
|
||||||
|
{
|
||||||
|
g_autoptr(SysprofDocumentTraceable) sample = g_list_model_get_item (samples, i);
|
||||||
|
gint64 time = sysprof_document_frame_get_time (SYSPROF_DOCUMENT_FRAME (sample));
|
||||||
|
guint depth = sysprof_document_traceable_get_stack_depth (sample);
|
||||||
|
|
||||||
|
sysprof_xy_series_add (samples_series, time, depth, i);
|
||||||
|
}
|
||||||
|
|
||||||
window = g_object_new (GTK_TYPE_WINDOW,
|
window = g_object_new (GTK_TYPE_WINDOW,
|
||||||
"default-width", 800,
|
"default-width", 800,
|
||||||
@ -92,8 +111,10 @@ main (int argc,
|
|||||||
chart = g_object_new (SYSPROF_TYPE_CHART,
|
chart = g_object_new (SYSPROF_TYPE_CHART,
|
||||||
"session", session,
|
"session", session,
|
||||||
"title", "Stack Traces",
|
"title", "Stack Traces",
|
||||||
|
"height-request", 128,
|
||||||
NULL);
|
NULL);
|
||||||
layer = g_object_new (SYSPROF_TYPE_DEPTH_LAYER,
|
layer = g_object_new (SYSPROF_TYPE_DEPTH_LAYER,
|
||||||
|
"series", samples_series,
|
||||||
NULL);
|
NULL);
|
||||||
sysprof_chart_add_layer (SYSPROF_CHART (chart),
|
sysprof_chart_add_layer (SYSPROF_CHART (chart),
|
||||||
SYSPROF_CHART_LAYER (layer));
|
SYSPROF_CHART_LAYER (layer));
|
||||||
|
|||||||
Reference in New Issue
Block a user