void print_objfile_statistics (void) { struct objfile *objfile; struct symtab *s; struct partial_symtab *ps; int i, linetables, blockvectors; immediate_quit++; ALL_OBJFILES (objfile) { printf_filtered (_("Statistics for '%s':\n"), objfile->name); if (OBJSTAT (objfile, n_stabs) > 0) printf_filtered (_(" Number of \"stab\" symbols read: %d\n"), OBJSTAT (objfile, n_stabs)); if (OBJSTAT (objfile, n_minsyms) > 0) printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"), OBJSTAT (objfile, n_minsyms)); if (OBJSTAT (objfile, n_psyms) > 0) printf_filtered (_(" Number of \"partial\" symbols read: %d\n"), OBJSTAT (objfile, n_psyms)); if (OBJSTAT (objfile, n_syms) > 0) printf_filtered (_(" Number of \"full\" symbols read: %d\n"), OBJSTAT (objfile, n_syms)); if (OBJSTAT (objfile, n_types) > 0) printf_filtered (_(" Number of \"types\" defined: %d\n"), OBJSTAT (objfile, n_types)); i = 0; ALL_OBJFILE_PSYMTABS (objfile, ps) { if (ps->readin == 0) i++; } printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i); i = linetables = blockvectors = 0; ALL_OBJFILE_SYMTABS (objfile, s) { i++; if (s->linetable != NULL) linetables++; if (s->primary == 1) blockvectors++; } printf_filtered (_(" Number of symbol tables: %d\n"), i); printf_filtered (_(" Number of symbol tables with line tables: %d\n"), linetables); printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"), blockvectors); if (OBJSTAT (objfile, sz_strtab) > 0) printf_filtered (_(" Space used by a.out string tables: %d\n"), OBJSTAT (objfile, sz_strtab)); printf_filtered (_(" Total memory used for objfile obstack: %d\n"), obstack_memory_used (&objfile->objfile_obstack)); printf_filtered (_(" Total memory used for psymbol cache: %d\n"), bcache_memory_used (objfile->psymbol_cache)); printf_filtered (_(" Total memory used for macro cache: %d\n"), bcache_memory_used (objfile->macro_cache)); }
void ht_dump_statistics (hash_table *table) { size_t nelts, nids, overhead, headers; size_t total_bytes, longest; double sum_of_squares, exp_len, exp_len2, exp2_len; hashnode *p, *limit; #define SCALE(x) ((unsigned long) ((x) < 1024*10 \ ? (x) \ : ((x) < 1024*1024*10 \ ? (x) / 1024 \ : (x) / (1024*1024)))) #define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M')) total_bytes = longest = sum_of_squares = nids = 0; p = table->entries; limit = p + table->nslots; do if (*p) { size_t n = HT_LEN (*p); total_bytes += n; sum_of_squares += (double) n * n; if (n > longest) longest = n; nids++; } while (++p < limit); nelts = table->nelements; overhead = obstack_memory_used (&table->stack) - total_bytes; headers = table->nslots * sizeof (hashnode); fprintf (stderr, "\nString pool\nentries\t\t%lu\n", (unsigned long) nelts); fprintf (stderr, "identifiers\t%lu (%.2f%%)\n", (unsigned long) nids, nids * 100.0 / nelts); fprintf (stderr, "slots\t\t%lu\n", (unsigned long) table->nslots); fprintf (stderr, "bytes\t\t%lu%c (%lu%c overhead)\n", SCALE (total_bytes), LABEL (total_bytes), SCALE (overhead), LABEL (overhead)); fprintf (stderr, "table size\t%lu%c\n", SCALE (headers), LABEL (headers)); exp_len = (double)total_bytes / (double)nelts; exp2_len = exp_len * exp_len; exp_len2 = (double) sum_of_squares / (double) nelts; fprintf (stderr, "coll/search\t%.4f\n", (double) table->collisions / (double) table->searches); fprintf (stderr, "ins/search\t%.4f\n", (double) nelts / (double) table->searches); fprintf (stderr, "avg. entry\t%.2f bytes (+/- %.2f)\n", exp_len, approx_sqrt (exp_len2 - exp2_len)); fprintf (stderr, "longest entry\t%lu\n", (unsigned long) longest); #undef SCALE #undef LABEL }