commit 6cf0b638631b1dc09719d468e537fc3a98cac8c3 from: Sven M. Hallberg date: Fri Jun 12 17:09:53 2020 UTC clean up profiling output and hide it behind -DPROFGROW commit - ba81fd47b2fc845a3b5e53e3203c9e67bca8fef7 commit + 6cf0b638631b1dc09719d468e537fc3a98cac8c3 blob - 1b3950f7c629dd6f556f022cdb590c93008588ef blob + 740aa382d9ba714b62d2116f82c3eab4a942e2a3 --- minip_m.h +++ minip_m.h @@ -265,13 +265,15 @@ memo_(struct stream inp, struct cache *cache, void *en newcap = 4; else newcap = cache->capacity * 2; - fprintf(stderr, "XXX grow at %zu/%zu -> newcap %zu\n", +#ifdef PROFGROW + size_t count=0, count2=0; + fprintf(stderr, "\tgrow at %zu/%zu -> newcap %zu\n", cache->nused, cache->capacity, newcap); +#endif newp = calloc(newcap, sizeof *cache->table); assert(newp != NULL); /* relocate items */ - size_t count=0, count2=0; // XXX for (i=0; i < cache->capacity; i++) { const char *pi = cache->table[i].position; const char *si = cache->table[i].symbol; @@ -293,21 +295,22 @@ memo_(struct stream inp, struct cache *cache, void *en if (mem->position == NULL) /* unused */ break; } +#ifdef PROFGROW if (s != 1) count2++; + if (h != i) + count++; +#endif /* copy the entry to the new array */ - if (h != i) { - fprintf(stderr, "XXX move %zu -> %u %s\n", - i, h, h < cache->capacity ? "(!)" : ""); - count++; // XXX - } *mem = cache->table[i]; } - fprintf(stderr, "XXX pos. changed on %zu/%zu entries = %.1f%%\n", +#ifdef PROFGROW + fprintf(stderr, "\tpos. changed on %zu/%zu entries = %.1f%%\n", count, cache->nused, count * 100.0 / cache->nused); - fprintf(stderr, "XXX now %zu/%zu are off-base, i.e. %.1f%%\n", + fprintf(stderr, "\tnow %zu/%zu are off-base, i.e. %.1f%%\n", count2, cache->nused, count2 * 100.0 / cache->nused); +#endif free(cache->table); cache->table = newp;