Print set-digest hit ratio with HB_DEBUG_SET_DIGESTS

This commit is contained in:
Behdad Esfahbod 2013-04-16 21:57:21 -04:00
parent 1357c2dd12
commit 4d2813d3e9
2 changed files with 26 additions and 0 deletions

View File

@ -102,6 +102,10 @@ struct hb_set_digest_lowest_bits_t
mask_t mask;
};
#ifdef HB_DEBUG_SET_DIGESTS
extern unsigned long digest_total, digest_yes, digest_yes1, digest_yes2;
#endif
struct hb_set_digest_t
{
ASSERT_POD ();
@ -122,6 +126,15 @@ struct hb_set_digest_t
}
inline bool may_have (hb_codepoint_t g) const {
#ifdef HB_DEBUG_SET_DIGESTS
digest_total++;
if (digest1.may_have (g) && digest2.may_have (g))
digest_yes++;
if (digest1.may_have (g))
digest_yes1++;
if (digest2.may_have (g))
digest_yes2++;
#endif
return digest1.may_have (g) && digest2.may_have (g);
}

View File

@ -27,6 +27,19 @@
#include "hb-set-private.hh"
#ifdef HB_DEBUG_SET_DIGESTS
unsigned long digest_total, digest_yes, digest_yes1, digest_yes2;
__attribute__((__destructor__))
void digest_print (void)
{
if (!digest_total)
return;
printf("Set digest summary: both %%%ld first %%%ld second %%%ld\n",
100 * digest_yes / digest_total,
100 * digest_yes1 / digest_total,
100 * digest_yes2 / digest_total);
}
#endif
/* Public API */