11
22#include " lvfontglyphcache_a.h"
33#include " lvfontglyphcache_b.h"
4+ #include " ../../src/private/lvfontglyphcache.h"
45#include " lvtypes.h"
56
67#include < stdio.h>
8+ #include < stdint.h>
79#include < sys/time.h>
810#include < limits.h>
911
@@ -271,7 +273,12 @@ int main(int /*argc*/, char* /*argv*/[])
271273 LVFontGlobalGlyphCacheB globalCacheB (0x40000 );
272274 LVFontLocalGlyphCacheB localCacheB (&globalCacheB, 256 );
273275 LVFontGlyphCacheItemB* itemB;
274- u_int64_t tmp;
276+
277+ LVFontGlobalGlyphCache globalCache (0x40000 );
278+ LVFontLocalGlyphCache localCache (&globalCache);
279+ LVFontGlyphCacheItem* item;
280+
281+ uint64_t tmp;
275282 struct timeval ts1;
276283 struct timeval ts2;
277284 int64_t elapsed;
@@ -296,10 +303,18 @@ int main(int /*argc*/, char* /*argv*/[])
296303 itemB->origin_y = 0 ;
297304 localCacheB.put (itemB);
298305 }
306+ item = LVFontGlyphCacheItem::newItem (&localCache, glyphCodes_tofill[i], 10 , 10 );
307+ if (item)
308+ {
309+ item->origin_x = 0 ;
310+ item->origin_y = 0 ;
311+ localCache.put (item);
312+ }
299313 }
300314
301315 printf (" size of global cacheA: %u\n " , globalCacheA.getSize ());
302316 printf (" size of global cacheB: %u\n " , globalCacheB.getSize ());
317+ printf (" size of global cache: no data...\n " );
303318
304319 // bench lookup based on linked list
305320 printf (" bench cache based on linked list...\n " );
@@ -319,7 +334,7 @@ int main(int /*argc*/, char* /*argv*/[])
319334 printf (" t = %lld\n " , tmp);
320335
321336 // bench lookup based on hash table
322- printf (" bench cache based on hash table...\n " );
337+ printf (" bench cache based on hash table (copy from cr3.2.32) ...\n " );
323338 gettimeofday (&ts1, NULL );
324339 for (j = 0 ; j < bench_sz; j++)
325340 {
@@ -334,9 +349,26 @@ int main(int /*argc*/, char* /*argv*/[])
334349 printf (" %lld us\n " , elapsed);
335350 printf (" t = %lld\n " , tmp);
336351
352+ // bench lookup based on hash table
353+ printf (" bench cache based on hash table (current version)...\n " );
354+ gettimeofday (&ts1, NULL );
355+ for (j = 0 ; j < bench_sz; j++)
356+ {
357+ for (i = 0 ; i < lookup_seq_sz; i++)
358+ {
359+ item = localCache.get (lookup_seq[i]);
360+ tmp += item->origin_x ;
361+ }
362+ }
363+ gettimeofday (&ts2, NULL );
364+ elapsed = timevalcmp (&ts2, &ts1);
365+ printf (" %lld us\n " , elapsed);
366+ printf (" t = %lld\n " , tmp);
367+
337368 // cleanup
338369 globalCacheA.clear ();
339370 globalCacheB.clear ();
371+ globalCache.clear ();
340372 return 0 ;
341373}
342374
0 commit comments