summaryrefslogtreecommitdiffstats
path: root/tests/storage/test_phrase_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-09-01 15:32:15 +0800
committerPeng Wu <alexepico@gmail.com>2010-09-01 15:32:15 +0800
commitcdb3ae7a7bab2970eedae28ee7d1a387847f51fd (patch)
tree2d23658e30d1309382dc12ae299b040c7a286a9f /tests/storage/test_phrase_table.cpp
parent7e544ad0d4261320ad4e2fa3228b9b81ed76ffb0 (diff)
downloadlibpinyin-cdb3ae7a7bab2970eedae28ee7d1a387847f51fd.tar.gz
libpinyin-cdb3ae7a7bab2970eedae28ee7d1a387847f51fd.tar.xz
libpinyin-cdb3ae7a7bab2970eedae28ee7d1a387847f51fd.zip
begin to write phrase large table test case
Diffstat (limited to 'tests/storage/test_phrase_table.cpp')
-rw-r--r--tests/storage/test_phrase_table.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp
new file mode 100644
index 0000000..691b1dc
--- /dev/null
+++ b/tests/storage/test_phrase_table.cpp
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <sys/time.h>
+#include "novel_types.h"
+#include "phrase_large_table.h"
+
+size_t bench_times = 1000;
+
+guint32 record_time ()
+{
+ timeval tv;
+ gettimeofday(&tv, NULL);
+ return (guint32) tv.tv_sec * 1000000 + tv.tv_usec;
+}
+
+void print_time (guint32 old_time, guint32 times)
+{
+ timeval tv;
+ gettimeofday (&tv, NULL);
+
+ guint32 wasted = (guint32) tv.tv_sec * 1000000 + tv.tv_usec - old_time;
+
+ printf("Spent %d us for %d operations, %f us/op, %f times/s.\n\n", wasted, times, ((double)wasted)/times, times * 1000000.0/wasted);
+}
+
+
+int main(int argc, char * argv[]){
+ PhraseLargeTable largetable;
+
+ FILE * gbfile = fopen("../../data/gb_char.table", "r");
+ if ( gbfile == NULL ) {
+ printf("open gb_char.table failed!\n");
+ return 1;
+ }
+
+ largetable.load_text(gbfile);
+ fclose(gbfile);
+
+ FILE * gbkfile = fopen("../../data/gbk_char.table", "r");
+ if (gbkfile == NULL ) {
+ printf("open gbk_char.table failed!\n");
+ return 1;
+ }
+
+ largetable.load_text(gbkfile);
+ fclose(gbkfile);
+
+
+}