Don't compute the total field.

Sat Nov  5 12:39:33 2005  Soeren Sandmann  <sandmann@redhat.com>

        * profile.c (add_trace_to_tree): Don't compute the total field.

        * profile.h (struct ProfileDescendant): Remove 'total' field.

        * sysprof.c: Delete DESCENDANTS_TOTAL column and everything
        related to it.

        * profile.c: Remove commented out code

        * sfile.c (handle_text): Don't copy the text
This commit is contained in:
Soeren Sandmann
2005-11-05 17:28:22 +00:00
committed by Søren Sandmann Pedersen
parent cf761a2a70
commit 1f5b6ff38c
5 changed files with 49 additions and 86 deletions

View File

@ -1,3 +1,16 @@
Sat Nov 5 12:39:33 2005 Soeren Sandmann <sandmann@redhat.com>
* profile.c (add_trace_to_tree): Don't compute the total field.
* profile.h (struct ProfileDescendant): Remove 'total' field.
* sysprof.c: Delete DESCENDANTS_TOTAL column and everything
related to it.
* profile.c: Remove commented out code
* sfile.c (handle_text): Don't copy the text
2005-11-04 Soren Sandmann <sandmann@redhat.com> 2005-11-04 Soren Sandmann <sandmann@redhat.com>
* collector.[ch]: Add copyright statement. * collector.[ch]: Add copyright statement.

View File

@ -165,25 +165,6 @@ profile_save (Profile *profile,
return result; return result;
} }
#if 0
static void
make_hash_table (Node *node, GHashTable *table)
{
if (!node)
return;
g_assert (node->object);
node->next = g_hash_table_lookup (table, node->object);
g_hash_table_insert (table, node->object, node);
g_assert (node->siblings != (void *)0x11);
make_hash_table (node->siblings, table);
make_hash_table (node->children, table);
}
#endif
Profile * Profile *
profile_load (const char *filename, GError **err) profile_load (const char *filename, GError **err)
{ {
@ -266,12 +247,9 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
{ {
GList *list; GList *list;
GPtrArray *nodes_to_unmark = g_ptr_array_new (); GPtrArray *nodes_to_unmark = g_ptr_array_new ();
GPtrArray *nodes_to_unmark_recursive = g_ptr_array_new ();
ProfileDescendant *parent = NULL; ProfileDescendant *parent = NULL;
int i, len; int i, len;
GPtrArray *seen_objects = g_ptr_array_new ();
for (list = trace; list != NULL; list = list->next) for (list = trace; list != NULL; list = list->next)
{ {
StackNode *node = list->data; StackNode *node = list->data;
@ -288,12 +266,12 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
if (!match) if (!match)
{ {
ProfileDescendant *seen_tree_node; ProfileDescendant *seen_tree_node;
ProfileDescendant *n;
/* Have we seen this object further up the tree? */ /* Have we seen this object further up the tree? */
seen_tree_node = NULL; seen_tree_node = NULL;
for (i = 0; i < seen_objects->len; ++i) for (n = parent; n != NULL; n = n->parent)
{ {
ProfileDescendant *n = seen_objects->pdata[i];
if (n->name == node->address) if (n->name == node->address)
seen_tree_node = n; seen_tree_node = n;
} }
@ -303,7 +281,7 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
ProfileDescendant *node; ProfileDescendant *node;
g_assert (parent); g_assert (parent);
for (node = parent; node != seen_tree_node->parent; node = node->parent) for (node = parent; node != seen_tree_node->parent; node = node->parent)
{ {
node->non_recursion -= size; node->non_recursion -= size;
@ -311,10 +289,6 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
} }
match = seen_tree_node; match = seen_tree_node;
g_ptr_array_remove_range (seen_objects, 0, seen_objects->len);
for (node = match; node != NULL; node = node->parent)
g_ptr_array_add (seen_objects, node);
} }
} }
@ -324,13 +298,10 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
match->name = node->address; match->name = node->address;
match->non_recursion = 0; match->non_recursion = 0;
match->total = 0;
match->self = 0; match->self = 0;
match->children = NULL; match->children = NULL;
match->marked_non_recursive = 0; match->marked_non_recursive = 0;
match->marked_total = FALSE;
match->parent = parent; match->parent = parent;
match->siblings = *tree; match->siblings = *tree;
*tree = match; *tree = match;
} }
@ -342,25 +313,13 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
++match->marked_non_recursive; ++match->marked_non_recursive;
} }
if (!match->marked_total)
{
g_ptr_array_add (nodes_to_unmark_recursive, match);
match->total += size;
match->marked_total = TRUE;
}
if (!list->next) if (!list->next)
match->self += size; match->self += size;
g_ptr_array_add (seen_objects, match);
tree = &(match->children); tree = &(match->children);
parent = match; parent = match;
} }
g_ptr_array_free (seen_objects, TRUE);
len = nodes_to_unmark->len; len = nodes_to_unmark->len;
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
{ {
@ -369,16 +328,7 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
tree_node->marked_non_recursive = 0; tree_node->marked_non_recursive = 0;
} }
len = nodes_to_unmark_recursive->len;
for (i = 0; i < len; ++i)
{
ProfileDescendant *tree_node = nodes_to_unmark_recursive->pdata[i];
tree_node->marked_total = FALSE;
}
g_ptr_array_free (nodes_to_unmark, TRUE); g_ptr_array_free (nodes_to_unmark, TRUE);
g_ptr_array_free (nodes_to_unmark_recursive, TRUE);
} }
static void static void

View File

@ -40,14 +40,12 @@ struct ProfileDescendant
{ {
char * name; char * name;
guint self; guint self;
guint total;
guint non_recursion; guint non_recursion;
ProfileDescendant * parent; ProfileDescendant * parent;
ProfileDescendant * siblings; ProfileDescendant * siblings;
ProfileDescendant * children; ProfileDescendant * children;
int marked_non_recursive; int marked_non_recursive;
int marked_total;
}; };
struct ProfileCaller struct ProfileCaller

59
sfile.c
View File

@ -569,10 +569,6 @@ state_transition_text (const State *state, SType *type, SType *target_type)
*/ */
return transition->to; return transition->to;
} }
#if 0
else
g_print ("transition: %d (%s)\n", transition->kind, transition->element);
#endif
} }
return NULL; return NULL;
@ -633,24 +629,29 @@ struct BuildContext
GArray *instructions; GArray *instructions;
}; };
static gboolean
is_all_blank (const char *text)
{
while (g_ascii_isspace (*text))
text++;
return (*text == '\0');
}
static gboolean static gboolean
get_number (const char *text, int *number) get_number (const char *text, int *number)
{ {
char *end; char *end;
int result; int result;
char *stripped;
gboolean retval; gboolean retval;
stripped = g_strstrip (g_strdup (text)); result = strtol (text, &end, 10);
result = strtol (stripped, &end, 10);
retval = (*end == '\0');
retval = is_all_blank (end);
if (retval && number) if (retval && number)
*number = result; *number = result;
g_free (stripped);
return retval; return retval;
} }
@ -914,6 +915,15 @@ decode_text (const char *text, char **decoded)
return TRUE; return TRUE;
} }
static const char *
skip_whitespace (const char *text)
{
while (g_ascii_isspace (*text))
text++;
return text;
}
static void static void
handle_text (GMarkupParseContext *context, handle_text (GMarkupParseContext *context,
const gchar *text, const gchar *text,
@ -923,24 +933,22 @@ handle_text (GMarkupParseContext *context,
{ {
BuildContext *build = user_data; BuildContext *build = user_data;
Instruction instruction; Instruction instruction;
char *free_me;
SType target_type; SType target_type;
text = free_me = g_strstrip (g_strdup (text)); if (*text == '\0')
return;
if (strlen (text) == 0)
goto out; text = skip_whitespace (text);
if (*text == '\0')
return;
build->state = state_transition_text (build->state, &instruction.type, &target_type); build->state = state_transition_text (build->state, &instruction.type, &target_type);
if (!build->state) if (!build->state)
{ {
int line, ch; int line, ch;
g_markup_parse_context_get_position (context, &line, &ch); g_markup_parse_context_get_position (context, &line, &ch);
#if 0
g_print ("line: %d char: %d\n", line, ch);
#endif
set_invalid_content_error (err, "Unexpected text data"); set_invalid_content_error (err, "Unexpected text data");
goto out; return;
} }
instruction.name = NULL; instruction.name = NULL;
@ -953,7 +961,7 @@ handle_text (GMarkupParseContext *context,
if (!get_number (text, &instruction.u.pointer.target_id)) if (!get_number (text, &instruction.u.pointer.target_id))
{ {
set_invalid_content_error (err, "Contents '%s' of pointer element is not a number", text); set_invalid_content_error (err, "Contents '%s' of pointer element is not a number", text);
goto out; return;
} }
break; break;
@ -961,7 +969,7 @@ handle_text (GMarkupParseContext *context,
if (!get_number (text, &instruction.u.integer.value)) if (!get_number (text, &instruction.u.integer.value))
{ {
set_invalid_content_error (err, "Contents '%s' of integer element not a number", text); set_invalid_content_error (err, "Contents '%s' of integer element not a number", text);
goto out; return;
} }
break; break;
@ -969,7 +977,7 @@ handle_text (GMarkupParseContext *context,
if (!decode_text (text, &instruction.u.string.value)) if (!decode_text (text, &instruction.u.string.value))
{ {
set_invalid_content_error (err, "Contents '%s' of text element is illformed", text); set_invalid_content_error (err, "Contents '%s' of text element is illformed", text);
goto out; return;
} }
break; break;
@ -979,9 +987,6 @@ handle_text (GMarkupParseContext *context,
} }
g_array_append_val (build->instructions, instruction); g_array_append_val (build->instructions, instruction);
out:
g_free (free_me);
} }
static void static void

View File

@ -384,7 +384,6 @@ enum
DESCENDANTS_NAME, DESCENDANTS_NAME,
DESCENDANTS_SELF, DESCENDANTS_SELF,
DESCENDANTS_NON_RECURSE, DESCENDANTS_NON_RECURSE,
DESCENDANTS_TOTAL,
DESCENDANTS_OBJECT DESCENDANTS_OBJECT
}; };
@ -486,7 +485,6 @@ add_node (GtkTreeStore *store,
DESCENDANTS_NAME, node->name, DESCENDANTS_NAME, node->name,
DESCENDANTS_SELF, 100 * (node->self)/(double)size, DESCENDANTS_SELF, 100 * (node->self)/(double)size,
DESCENDANTS_NON_RECURSE, 100 * (node->non_recursion)/(double)size, DESCENDANTS_NON_RECURSE, 100 * (node->non_recursion)/(double)size,
DESCENDANTS_TOTAL, 100 * (node->total)/(double)size,
DESCENDANTS_OBJECT, node->name, DESCENDANTS_OBJECT, node->name,
-1); -1);
@ -509,11 +507,10 @@ fill_descendants_tree (Application *app)
} }
tree_store = tree_store =
gtk_tree_store_new (5, gtk_tree_store_new (4,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_DOUBLE, G_TYPE_DOUBLE,
G_TYPE_DOUBLE, G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
G_TYPE_POINTER); G_TYPE_POINTER);
if (app->profile) if (app->profile)