freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype-demos][master] [graph] Count the number of hash


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] [graph] Count the number of hash clashes.
Date: Tue, 23 Aug 2022 03:21:57 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • ecaa7996
    by Alexei Podtelezhnikov at 2022-08-22T23:08:10-04:00
    [graph] Count the number of hash clashes.
    
    The hash table lookups take very noticeable time when rendering is
    complex like in `ftgrid`.  This can help optimize the hash function.
    
    * graph/gblender.h (GBLENDER_STATS): New field for clashes.
    * graph/gblender.c (gblender_init, gblender_lookup{,_channel},
    gblender_dump_stats): Initialize, collect, and report clashes.
    

2 changed files:

Changes:

  • graph/gblender.c
    ... ... @@ -167,6 +167,7 @@ gblender_init( GBlender blender,
    167 167
     #ifdef GBLENDER_STATS
    
    168 168
       blender->stat_hits    = 0;
    
    169 169
       blender->stat_lookups = 0;
    
    170
    +  blender->stat_clashes = 0;
    
    170 171
       blender->stat_keys    = 0;
    
    171 172
       blender->stat_clears  = 0;
    
    172 173
     #endif
    
    ... ... @@ -308,6 +309,9 @@ NewNode:
    308 309
     #endif
    
    309 310
     
    
    310 311
     Exit:
    
    312
    +#ifdef GBLENDER_STATS
    
    313
    +  blender->stat_clashes += ( idx - idx0 ) & (GBLENDER_KEY_COUNT-1);
    
    314
    +#endif
    
    311 315
       return  key->cells;
    
    312 316
     }
    
    313 317
     
    
    ... ... @@ -399,6 +403,9 @@ NewNode:
    399 403
     #endif
    
    400 404
     
    
    401 405
     Exit:
    
    406
    +#ifdef GBLENDER_STATS
    
    407
    +  blender->stat_clashes += ( idx - idx0 ) & (GBLENDER_KEY_COUNT-1);
    
    408
    +#endif
    
    402 409
       return  (unsigned char*)blender->cells + key->index;
    
    403 410
     }
    
    404 411
     
    
    ... ... @@ -421,6 +428,7 @@ gblender_dump_stats( GBlender blender )
    421 428
                        blender->stat_lookups,
    
    422 429
               blender->stat_lookups - blender->stat_keys,
    
    423 430
               blender->stat_lookups );
    
    431
    +  printf( "  Clashes:     %ld\n", blender->stat_clashes );
    
    424 432
       printf( "  Keys used:   %ld\n  Caches full: %ld\n",
    
    425 433
               blender->stat_keys, blender->stat_clears );
    
    426 434
     }
    

  • graph/gblender.h
    ... ... @@ -107,6 +107,7 @@
    107 107
     #ifdef GBLENDER_STATS
    
    108 108
         long                  stat_hits;    /* number of direct hits             */
    
    109 109
         long                  stat_lookups; /* number of table lookups           */
    
    110
    +    long                  stat_clashes; /* number of table clashes           */
    
    110 111
         long                  stat_keys;    /* number of table key recomputation */
    
    111 112
         long                  stat_clears;  /* number of table clears            */
    
    112 113
     #endif
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]