+typedef struct {
+ MonoClass *klass;
+ guint count;
+} NewobjProfile;
+
+static gint
+compare_newobj_profile (NewobjProfile *profa, NewobjProfile *profb)
+{
+ return (gint)profb->count - (gint)profa->count;
+}
+
+static void
+build_newobj_profile (MonoClass *class, gpointer count, GList **funcs)
+{
+ NewobjProfile *prof = g_new (NewobjProfile, 1);
+ prof->klass = class;
+ prof->count = GPOINTER_TO_UINT (count);
+ *funcs = g_list_insert_sorted (*funcs, prof, (GCompareFunc)compare_newobj_profile);
+}
+
+static void
+output_newobj_profile (GList *proflist)
+{
+ GList *tmp;
+ NewobjProfile *p;
+ MonoClass *klass;
+ char* isarray;
+ char buf [256];
+
+ if (proflist)
+ g_print ("\n%-52s %9s\n", "Objects created:", "count");
+ for (tmp = proflist; tmp; tmp = tmp->next) {
+ p = tmp->data;
+ klass = p->klass;
+ if (strcmp (klass->name, "Array") == 0) {
+ isarray = "[]";
+ klass = klass->element_class;
+ } else {
+ isarray = "";
+ }
+ g_snprintf (buf, sizeof (buf), "%s.%s%s",
+ klass->name_space, klass->name, isarray);
+ g_print ("%-52s %9d\n", buf, p->count);
+ }
+}
+