+
+/* Output per-varray statistics. */
+#ifdef GATHER_STATISTICS
+
+/* Used to accumulate statistics about varray sizes. */
+struct output_info
+{
+ int count;
+ int size;
+};
+
+/* Called via htab_traverse. Output varray descriptor pointed out by SLOT
+ and update statistics. */
+static int
+print_statistics (void **slot, void *b)
+{
+ struct varray_descriptor *d = (struct varray_descriptor *) *slot;
+ struct output_info *i = (struct output_info *) b;
+
+ if (d->allocated)
+ {
+ fprintf (stderr, "%-21s %6d %10d %7d %7d\n", d->name,
+ d->created, d->allocated, d->resized, d->copied);
+ i->size += d->allocated;
+ i->count += d->created;
+ }
+ return 1;
+}
+#endif
+
+/* Output per-varray memory usage statistics. */
+void dump_varray_statistics (void)
+{
+#ifdef GATHER_STATISTICS
+ struct output_info info;
+
+ fprintf (stderr, "\nVARRAY Kind Count Bytes Resized copied\n");
+ fprintf (stderr, "-------------------------------------------------------\n");
+ info.count = 0;
+ info.size = 0;
+ htab_traverse (varray_hash, print_statistics, &info);
+ fprintf (stderr, "-------------------------------------------------------\n");
+ fprintf (stderr, "%-20s %7d %10d\n",
+ "Total", info.count, info.size);
+ fprintf (stderr, "-------------------------------------------------------\n");
+#endif
+}