Add a mono_g_hash_table_print_stats () function to print hash table stats.
authorZoltan Varga <vargaz@gmail.com>
Fri, 27 Aug 2010 20:06:20 +0000 (22:06 +0200)
committerZoltan Varga <vargaz@gmail.com>
Fri, 27 Aug 2010 20:07:15 +0000 (22:07 +0200)
mono/metadata/mono-hash.c
mono/metadata/mono-hash.h

index 84aac36dc8ccc98176d5e592681bd5dedc2e5d71..7263e8cc952e2d869e4a0d765a2c095d524cfdd6 100644 (file)
@@ -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
index 2e66f8edbde1541349776904bc45e2bc97db3f4a..79c80b78d8dfe1824eff324cf7a568a7eba6b0be 100644 (file)
@@ -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__ */