[Groonga-commit] groonga/groonga at 4f16b72 [master] benchmark nfkc: add char_type

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Jun 25 23:23:15 JST 2016


Kouhei Sutou	2016-06-25 23:23:15 +0900 (Sat, 25 Jun 2016)

  New Revision: 4f16b72b9142a409c07f267d1099f75b6eaa5661
  https://github.com/groonga/groonga/commit/4f16b72b9142a409c07f267d1099f75b6eaa5661

  Message:
    benchmark nfkc: add char_type

  Modified files:
    benchmark/bench-nfkc.c

  Modified: benchmark/bench-nfkc.c (+55 -8)
===================================================================
--- benchmark/bench-nfkc.c    2016-06-25 23:13:03 +0900 (34dfeac)
+++ benchmark/bench-nfkc.c    2016-06-25 23:23:15 +0900 (dd63e81)
@@ -88,6 +88,30 @@ ucs2utf8(unsigned int i, unsigned char *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)
 {
   uint64_t code_point;
@@ -181,6 +205,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)
 {
   uint64_t code_point;
@@ -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
 
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index