Skip to content

Commit 2d47e03

Browse files
committed
Updated subproject glyphcache_bench to test current glyph cache implementation.
1 parent 905b370 commit 2d47e03

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

crengine/Tools/glyphcache_bench/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@ set(SRC_LIST
55
lvfontglyphcache_b.cpp
66
)
77

8+
set(crengine_part_SRC_LIST
9+
../../src/crconcurrent.cpp
10+
../../src/lvstring.cpp
11+
../../src/lvmemman.cpp
12+
../../src/lvstream.cpp
13+
../../src/crtxtenc.cpp
14+
../../src/cp_stats.cpp
15+
../../src/private/lvfontglyphcache.cpp
16+
)
17+
818
if(WIN32)
919
add_definitions(-DWIN32 -D_CONSOLE)
1020
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mconsole")
1121
endif(WIN32)
1222

13-
add_executable(glyphcache_bench ${SRC_LIST})
14-
#target_link_libraries(glyphcache_bench)
23+
add_executable(glyphcache_bench ${SRC_LIST} ${crengine_part_SRC_LIST})
24+
target_link_libraries(glyphcache_bench ${ZLIB_LIBRARIES})
1525

1626
configure_file(valgrind_check.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/valgrind_check.sh)

crengine/Tools/glyphcache_bench/main.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
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

Comments
 (0)