summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-12-20 15:28:53 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2007-12-20 15:28:53 +0000
commit394b673c3b7703e0f12e7a1d813a8e5689ef9673 (patch)
treec3061316ddfe80cec152f8281f448ee67fedced5
parent650d06b4d317fa47ae0882c9908de95d9501ff49 (diff)
Add a currently allocated summary.
-rw-r--r--src/allocators-store.c24
-rw-r--r--src/allocators.h3
-rw-r--r--src/app.c23
-rw-r--r--src/odin.h2
-rw-r--r--src/summary-chart.c1
-rw-r--r--src/summary.c62
6 files changed, 95 insertions, 20 deletions
diff --git a/src/allocators-store.c b/src/allocators-store.c
index 9c5b76b..41e30c1 100644
--- a/src/allocators-store.c
+++ b/src/allocators-store.c
@@ -479,15 +479,15 @@ allocators_store_update (AllocatorsStore *store)
GtkTreeIter iter;
gint index[1];
guint old_len, n;
- gint *new_order;
struct _sum_allocator *sum;
GPtrArray *allocators;
path.indices = index;
iter.stamp = 1;
- if (store->allocators && store->allocators->len > 1) {
+ if (store->allocators) {
gboolean reordered = FALSE;
+ gint *new_order;
old_len = store->allocators->len;
g_ptr_array_sort (store->allocators, store->sum_allocators_cmp);
@@ -518,11 +518,11 @@ allocators_store_update (AllocatorsStore *store)
if (sum->count) {
g_ptr_array_add (allocators, sum);
} else {
- if (sum->old_index != (guint) -1) {
+ if (sum->old_index != (guint) -1 && sum->index != (guint) -1) {
g_assert (store->allocators != NULL);
path.indices[0] = sum->index;
gtk_tree_model_row_deleted ((GtkTreeModel *) store, &path);
- for (n = sum->old_index; n < store->allocators->len; n++) {
+ for (n = sum->old_index + 1; n < store->allocators->len; n++) {
((struct _sum_allocator *) g_ptr_array_index (store->allocators, n))->index--;
}
}
@@ -546,7 +546,8 @@ allocators_store_update (AllocatorsStore *store)
void
allocators_store_update_from_allocators (AllocatorsStore *store,
- Allocator *allocators)
+ Allocator *allocators,
+ gboolean total)
{
Allocator *A;
struct _sum_allocator *sum;
@@ -557,8 +558,10 @@ allocators_store_update_from_allocators (AllocatorsStore *store,
if (A->time_tail->n_allocs == 0)
continue;
- sum = allocators_store_get_sum (store, A->alloc_fn);
+ if (! total && A->time_tail->n_allocs == A->time_tail->n_frees)
+ continue;
+ sum = allocators_store_get_sum (store, A->alloc_fn);
if (sum == NULL)
sum = allocators_store_new_sum (store, A->alloc_fn);
@@ -566,8 +569,13 @@ allocators_store_update_from_allocators (AllocatorsStore *store,
A->time_tail->bytes > sum->largest->time_tail->bytes)
sum->largest = A;
- sum->size += A->time_tail->bytes;
- sum->count += A->time_tail->n_allocs;
+ if (total) {
+ sum->size += A->time_tail->bytes;
+ sum->count += A->time_tail->n_allocs;
+ } else {
+ sum->size += A->time_tail->bytes - A->time_tail->freed;
+ sum->count += A->time_tail->n_allocs - A->time_tail->n_frees;
+ }
}
allocators_store_update (store);
diff --git a/src/allocators.h b/src/allocators.h
index 5e75c39..839f438 100644
--- a/src/allocators.h
+++ b/src/allocators.h
@@ -83,6 +83,7 @@ allocators_store_update (AllocatorsStore *store);
void
allocators_store_update_from_allocators (AllocatorsStore *store,
- Allocator *allocators);
+ Allocator *allocators,
+ gboolean total);
#endif /* ALLOCATORS_H */
diff --git a/src/app.c b/src/app.c
index aae3465..2b18978 100644
--- a/src/app.c
+++ b/src/app.c
@@ -50,7 +50,8 @@ struct _app {
GtkWidget *window;
GtkWidget *notebook;
- GtkWidget *summary;
+ GtkWidget *summary_total;
+ GtkWidget *summary_current;
struct {
GtkWidget *allocators;
GtkWidget *block_map;
@@ -946,7 +947,8 @@ main_window_create (App *app)
app->spacetime = spacetime_new ();
- app->summary = summary_new ();
+ app->summary_total = summary_new (TRUE);
+ app->summary_current = summary_new (FALSE);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (app->allocations.call_graph));
g_signal_connect (selection, "changed",
@@ -992,9 +994,16 @@ main_window_create (App *app)
gtk_widget_show (app->statusbar);
label = gtk_label_new ("Summary");
- gtk_notebook_append_page (GTK_NOTEBOOK (app->notebook), app->summary, label);
+ gtk_notebook_append_page (GTK_NOTEBOOK (app->notebook),
+ app->summary_total, label);
+ gtk_widget_show (label);
+ gtk_widget_show (app->summary_total);
+
+ label = gtk_label_new ("Current");
+ gtk_notebook_append_page (GTK_NOTEBOOK (app->notebook),
+ app->summary_current, label);
gtk_widget_show (label);
- gtk_widget_show (app->summary);
+ gtk_widget_show (app->summary_current);
hbox = gtk_hbox_new (FALSE, 2);
label = gtk_label_new ("Allocation Map");
@@ -1873,7 +1882,8 @@ _update_client (App *app)
app->client.allocators,
app->client.last);
- summary_update ((Summary *) app->summary, &app->client);
+ summary_update ((Summary *) app->summary_total, &app->client);
+ summary_update ((Summary *) app->summary_current, &app->client);
timeline_add_datum ((Timeline *) app->timeline, &app->client,
app->client.time, app->client.allocators);
@@ -2074,7 +2084,8 @@ app_add_alloc_fn (App *app, const gchar *pattern, GError **error)
/* XXX signal */
call_graph_store_filter (app->client.call_graph, app);
- summary_update ((Summary *) app->summary, &app->client);
+ summary_update ((Summary *) app->summary_total, &app->client);
+ summary_update ((Summary *) app->summary_current, &app->client);
if (app->client.blocks != NULL)
app_set_blocks (app, app->client.blocks);
diff --git a/src/odin.h b/src/odin.h
index 1f66b5b..ef17348 100644
--- a/src/odin.h
+++ b/src/odin.h
@@ -245,7 +245,7 @@ G_CONST_RETURN Event *
app_find_prev_event_for_addr_range (App *app, guint time, gulong min, gulong max);
GtkWidget *
-summary_new (void);
+summary_new (gboolean total);
void
summary_update (Summary *summary, Client *client);
diff --git a/src/summary-chart.c b/src/summary-chart.c
index 36f6ccb..b6a84e7 100644
--- a/src/summary-chart.c
+++ b/src/summary-chart.c
@@ -516,7 +516,6 @@ summary_chart_class_init (SummaryChartClass *klass)
G_PARAM_STATIC_BLURB |
G_PARAM_STATIC_NAME |
G_PARAM_READWRITE));
-
}
diff --git a/src/summary.c b/src/summary.c
index b8248b9..4f19614 100644
--- a/src/summary.c
+++ b/src/summary.c
@@ -26,10 +26,15 @@
#include "allocators.h"
#include "summary.h"
+#ifndef _
+#define _(x) x
+#endif
+
struct _summary {
GtkFrame bin;
AllocatorsStore *store;
+ gboolean total;
};
typedef struct _summary_class {
@@ -41,9 +46,58 @@ summary_get_type (void);
G_DEFINE_TYPE (Summary, summary, GTK_TYPE_FRAME)
+enum {
+ PROP_0 = 0,
+ PROP_TOTAL
+};
+
+static void
+summary_set_property (GObject *obj, guint id, const GValue *v, GParamSpec *spec)
+{
+ Summary *self = (Summary *) obj;
+ switch (id) {
+ case PROP_TOTAL:
+ self->total = g_value_get_boolean (v);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, spec);
+ break;
+ }
+}
+
+static void
+summary_get_property (GObject *obj, guint id, GValue *v, GParamSpec *spec)
+{
+ Summary *self = (Summary *) obj;
+ switch (id) {
+ case PROP_TOTAL:
+ g_value_set_boolean (v, self->total);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, spec);
+ break;
+ }
+}
+
+
static void
summary_class_init (SummaryClass *klass)
{
+ GObjectClass *object_class = (GObjectClass *) klass;
+
+ object_class->set_property = summary_set_property;
+ object_class->get_property = summary_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_TOTAL,
+ g_param_spec_boolean ("total",
+ _("total"),
+ _("Total"),
+ TRUE,
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_READWRITE));
}
static void
@@ -52,6 +106,7 @@ summary_init (Summary *self)
GtkWidget *hbox, *w, *sw;
self->store = allocators_store_new ();
+ self->total = TRUE;
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (self), hbox);
@@ -73,16 +128,17 @@ summary_init (Summary *self)
}
GtkWidget *
-summary_new (void)
+summary_new (gboolean total)
{
- return g_object_new (summary_get_type (), NULL);
+ return g_object_new (summary_get_type (), "total", total, NULL);
}
void
summary_update (Summary *summary, Client *client)
{
allocators_store_update_from_allocators (summary->store,
- client->allocators);
+ client->allocators,
+ summary->total);
gtk_widget_queue_draw ((GtkWidget *) summary); /* XXX */
}