Permalink
Browse files

Add a mono_g_hash_table_print_stats () function to print hash table s…

…tats.
  • Loading branch information...
1 parent c20627e commit 536d37a44b4b13707e1b2876a83b597c5478bccd @vargaz vargaz committed Aug 27, 2010
Showing with 20 additions and 1 deletion.
  1. +18 −1 mono/metadata/mono-hash.c
  2. +2 −0 mono/metadata/mono-hash.h
View
@@ -468,6 +468,23 @@ mono_g_hash_table_replace(MonoGHashTable *h, gpointer k, gpointer v)
mono_g_hash_table_insert_replace (h, k, v, TRUE);
}
+void
+mono_g_hash_table_print_stats (MonoGHashTable *table)
+{
+ int i, chain_size, max_chain_size;
+ Slot *node;
+
+ max_chain_size = 0;
+ for (i = 0; i < table->table_size; i++) {
+ chain_size = 0;
+ for (node = table->table [i]; node; node = node->next)
+ chain_size ++;
+ max_chain_size = MAX(max_chain_size, chain_size);
+ }
+
+ printf ("Size: %d Table Size: %d Max Chain Length: %d\n", table->in_use, table->table_size, max_chain_size);
+}
+
#ifdef HAVE_SGEN_GC
/* GC marker function */
@@ -503,5 +520,5 @@ mono_g_hash_mark (void *addr, MonoGCMarkFunc mark_func)
}
}
}
-
+
#endif
@@ -96,6 +96,8 @@ void mono_g_hash_table_remap (MonoGHashTable *hash_table,
MonoGRemapperFunc func,
gpointer user_data);
+void mono_g_hash_table_print_stats (MonoGHashTable *table);
+
G_END_DECLS
#endif /* __MONO_G_HASH_H__ */

0 comments on commit 536d37a

Please sign in to comment.