Skip to content

Commit

Permalink
benchmark nfkc: add char_type
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 25, 2016
1 parent 73f5bb8 commit 4f16b72
Showing 1 changed file with 55 additions and 8 deletions.
63 changes: 55 additions & 8 deletions benchmark/bench-nfkc.c
Expand Up @@ -87,6 +87,30 @@ ucs2utf8(unsigned int i, unsigned char *buf)
return (p - buf);
}

static void
bench_char_type_switch(gpointer user_data)
{
uint64_t code_point;
char utf8[7];

for (code_point = 1; code_point < MAX_UNICODE; code_point++) {
ucs2utf8(code_point, (unsigned char *)utf8);
grn_nfkc_char_type(utf8);
}
}

static void
bench_char_type_table(gpointer user_data)
{
uint64_t code_point;
char utf8[7];

for (code_point = 1; code_point < MAX_UNICODE; code_point++) {
ucs2utf8(code_point, (unsigned char *)utf8);
grn_nfkc50_char_type(utf8);
}
}

static void
bench_map1_switch(gpointer user_data)
{
Expand Down Expand Up @@ -180,6 +204,26 @@ bench_map2_table_change(gpointer user_data)
}

/*
static void
check_char_type(gpointer user_data)
{
uint64_t code_point;
char utf8[7];
for (code_point = 1; code_point < MAX_UNICODE; code_point++) {
grn_char_type a;
grn_char_type b;
ucs2utf8(code_point, (unsigned char *)utf8);
a = grn_nfkc_char_type(utf8);
b = grn_nfkc50_char_type(utf8);
if (a == b) {
continue;
}
printf("%lx: %s: %d != %d\n", code_point, utf8, a, b);
}
}
static void
check_map1(gpointer user_data)
{
Expand Down Expand Up @@ -278,16 +322,19 @@ main(int argc, gchar **argv)
bench_function, \
NULL, \
NULL)
REGISTER("map1 - switch ", bench_map1_switch);
REGISTER("map1 - table ", bench_map1_table);
REGISTER("map2 - switch - no change", bench_map2_switch_no_change);
REGISTER("map2 - table - no change", bench_map2_table_no_change);
REGISTER("map2 - switch - change", bench_map2_switch_change);
REGISTER("map2 - table - change", bench_map2_table_change);
REGISTER("char_type - switch ", bench_char_type_switch);
REGISTER("char_type - table ", bench_char_type_table);
REGISTER("map1 - switch ", bench_map1_switch);
REGISTER("map1 - table ", bench_map1_table);
REGISTER("map2 - switch - no change", bench_map2_switch_no_change);
REGISTER("map2 - table - no change", bench_map2_table_no_change);
REGISTER("map2 - switch - change", bench_map2_switch_change);
REGISTER("map2 - table - change", bench_map2_table_change);

/*
REGISTER("check - map1", check_map1);
REGISTER("check - map2", check_map2);
REGISTER("check - char_type", check_char_type);
REGISTER("check - map1 ", check_map1);
REGISTER("check - map2 ", check_map2);
*/
#undef REGISTER

Expand Down

0 comments on commit 4f16b72

Please sign in to comment.