This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH for PR 14699
- From: Serge Belyshev <1319 at bot dot ru>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 24 Mar 2004 03:18:10 +0300
- Subject: PATCH for PR 14699
This patch fixes calculation of allocation statistics in hashtable.c (PR 14699)
on mainline.
2004-03-24 Serge Belyshev <1319@bot.ru>
PR 14699
* hashtable.c (ht_dump_statistics): fix calculation of allocation
statistics.
Index: hashtable.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/hashtable.c,v
retrieving revision 1.16
diff -c -3 -p -r1.16 hashtable.c
*** hashtable.c 22 Aug 2003 22:29:17 -0000 1.16
--- hashtable.c 24 Mar 2004 00:02:56 -0000
*************** void
*** 228,238 ****
ht_dump_statistics (hash_table *table)
{
size_t nelts, nids, overhead, headers;
! size_t total_bytes, longest, sum_of_squares;
! double exp_len, exp_len2, exp2_len;
hashnode *p, *limit;
! #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
? (x) \
: ((x) < 1024*1024*10 \
? (x) / 1024 \
--- 228,238 ----
ht_dump_statistics (hash_table *table)
{
size_t nelts, nids, overhead, headers;
! size_t longest;
! double total_bytes, sum_of_squares, exp2_sd;
hashnode *p, *limit;
! #define SCALE(x) (((x) < 1024*10 \
? (x) \
: ((x) < 1024*1024*10 \
? (x) / 1024 \
*************** ht_dump_statistics (hash_table *table)
*** 248,262 ****
size_t n = HT_LEN (*p);
total_bytes += n;
! sum_of_squares += 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",
--- 248,265 ----
size_t n = HT_LEN (*p);
total_bytes += n;
! sum_of_squares += (double) n * n;
if (n > longest)
longest = n;
nids++;
}
while (++p < limit);
!
! exp2_sd = (sum_of_squares - total_bytes * total_bytes / nids)
! / (double) (nids - 1);
!
nelts = table->nelements;
! overhead = obstack_memory_used (&table->stack) - (size_t) total_bytes;
headers = table->nslots * sizeof (hashnode);
fprintf (stderr, "\nString pool\nentries\t\t%lu\n",
*************** ht_dump_statistics (hash_table *table)
*** 265,286 ****
(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
--- 268,284 ----
(unsigned long) nids, nids * 100.0 / nelts);
fprintf (stderr, "slots\t\t%lu\n",
(unsigned long) table->nslots);
! fprintf (stderr, "bytes\t\t%.0f%c (%lu%c overhead)\n",
SCALE (total_bytes), LABEL (total_bytes),
! (unsigned long) SCALE (overhead), LABEL (overhead));
fprintf (stderr, "table size\t%lu%c\n",
! (unsigned long) SCALE (headers), LABEL (headers));
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",
! total_bytes / nids, approx_sqrt (exp2_sd));
fprintf (stderr, "longest entry\t%lu\n",
(unsigned long) longest);
#undef SCALE