Flutter Engine
The Flutter Engine
Classes | Macros | Typedefs | Functions | Variables
FontCacheBench.cpp File Reference
#include "bench/Benchmark.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkFont.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkString.h"
#include "include/private/base/SkTemplates.h"
#include "src/core/SkChecksum.h"
#include "tools/fonts/FontToolUtils.h"
#include "bench/gUniqueGlyphIDs.h"

Go to the source code of this file.

Classes

class  FontCacheBench
 
class  FontCacheEfficiency
 
class  FontPathBench
 

Macros

#define gUniqueGlyphIDs_Sentinel   0xFFFF
 
#define kMaxHashBits   12
 
#define kMaxHashCount   (1 << kMaxHashBits)
 

Typedefs

typedef uint32_t(* HasherProc) (uint32_t)
 

Functions

static int count_glyphs (const uint16_t start[])
 
static uint32_t rotr (uint32_t value, unsigned bits)
 
static uint32_t hasher0 (uint32_t value)
 
static int count_collisions (const uint16_t array[], int count, HasherProc proc, unsigned hashMask)
 
static void dump_array (const uint16_t array[], int count)
 

Variables

struct {
   const char *   fName
 
   HasherProc   fHasher
 
gRec []
 

Macro Definition Documentation

◆ gUniqueGlyphIDs_Sentinel

#define gUniqueGlyphIDs_Sentinel   0xFFFF

Definition at line 20 of file FontCacheBench.cpp.

◆ kMaxHashBits

#define kMaxHashBits   12

Definition at line 78 of file FontCacheBench.cpp.

◆ kMaxHashCount

#define kMaxHashCount   (1 << kMaxHashBits)

Definition at line 79 of file FontCacheBench.cpp.

Typedef Documentation

◆ HasherProc

typedef uint32_t(* HasherProc) (uint32_t)

Definition at line 63 of file FontCacheBench.cpp.

Function Documentation

◆ count_collisions()

static int count_collisions ( const uint16_t  array[],
int  count,
HasherProc  proc,
unsigned  hashMask 
)
static

Definition at line 81 of file FontCacheBench.cpp.

82 {
83 char table[kMaxHashCount];
84 sk_bzero(table, sizeof(table));
85
86 int collisions = 0;
87 for (int i = 0; i < count; ++i) {
88 int index = proc(array[i]) & hashMask;
89 collisions += table[index];
90 table[index] = 1;
91 }
92 return collisions;
93}
#define kMaxHashCount
sk_bzero(glyphs, sizeof(glyphs))
int count
Definition: FontMgrTest.cpp:50
SI F table(const skcms_Curve *curve, F v)

◆ count_glyphs()

static int count_glyphs ( const uint16_t  start[])
static

Definition at line 22 of file FontCacheBench.cpp.

22 {
23 const uint16_t* curr = start;
24 while (*curr != gUniqueGlyphIDs_Sentinel) {
25 curr += 1;
26 }
27 return static_cast<int>(curr - start);
28}
#define gUniqueGlyphIDs_Sentinel

◆ dump_array()

static void dump_array ( const uint16_t  array[],
int  count 
)
static

Definition at line 95 of file FontCacheBench.cpp.

95 {
96 for (int i = 0; i < count; ++i) {
97 SkDebugf(" %d,", array[i]);
98 }
99 SkDebugf("\n");
100}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1

◆ hasher0()

static uint32_t hasher0 ( uint32_t  value)
static

Definition at line 65 of file FontCacheBench.cpp.

65 {
66 value = value ^ (value >> 16);
67 return value ^ (value >> 8);
68}
uint8_t value

◆ rotr()

static uint32_t rotr ( uint32_t  value,
unsigned  bits 
)
static

Definition at line 59 of file FontCacheBench.cpp.

59 {
60 return (value >> bits) | (value << (32 - bits));
61}

Variable Documentation

◆ fHasher

HasherProc fHasher

Definition at line 72 of file FontCacheBench.cpp.

◆ fName

const char* fName

Definition at line 71 of file FontCacheBench.cpp.

◆ 

const struct { ... } gRec[]
Initial value:
= {
{ "hasher0", hasher0 },
{ "hasher2", SkChecksum::Mix },
}
static uint32_t hasher0(uint32_t value)
static uint32_t Mix(uint32_t hash)
Definition: SkChecksum.h:30