diff options
author | Peng Wu <alexepico@gmail.com> | 2011-11-29 15:51:22 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-11-29 16:00:37 +0800 |
commit | 192b5d79a24c36f0c1247bf837e2e837098145f6 (patch) | |
tree | 60b95981a8cc787fe69a42e9406900422a653c3f /tests/storage | |
parent | 15cb3e9a981848bd1ad14a09067c102196c743db (diff) | |
download | libpinyin-192b5d79a24c36f0c1247bf837e2e837098145f6.tar.gz libpinyin-192b5d79a24c36f0c1247bf837e2e837098145f6.tar.xz libpinyin-192b5d79a24c36f0c1247bf837e2e837098145f6.zip |
refactor test cases
Diffstat (limited to 'tests/storage')
-rw-r--r-- | tests/storage/Makefile.am | 1 | ||||
-rw-r--r-- | tests/storage/test_phrase_index.cpp | 21 | ||||
-rw-r--r-- | tests/storage/test_phrase_table.cpp | 21 | ||||
-rw-r--r-- | tests/storage/test_pinyin_index.cpp | 21 |
4 files changed, 4 insertions, 60 deletions
diff --git a/tests/storage/Makefile.am b/tests/storage/Makefile.am index 87f5504..54de6af 100644 --- a/tests/storage/Makefile.am +++ b/tests/storage/Makefile.am @@ -19,6 +19,7 @@ INCLUDES = -I$(top_srcdir)/src \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/storage \ -I$(top_srcdir)/src/lookup \ + -I$(top_srcdir)/tests \ @GLIB2_CPPFLAGS@ noinst_PROGRAMS = test_parser \ diff --git a/tests/storage/test_phrase_index.cpp b/tests/storage/test_phrase_index.cpp index 8f22a7d..066176c 100644 --- a/tests/storage/test_phrase_index.cpp +++ b/tests/storage/test_phrase_index.cpp @@ -1,29 +1,10 @@ +#include "timer.h" #include <stdio.h> -#include <sys/time.h> #include <errno.h> -#include <glib.h> #include "pinyin_internal.h" size_t bench_times = 100000; -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[]){ PhraseItem phrase_item; utf16_t string1 = 2; diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp index 1bab4cf..a4e3a30 100644 --- a/tests/storage/test_phrase_table.cpp +++ b/tests/storage/test_phrase_table.cpp @@ -1,28 +1,9 @@ +#include "timer.h" #include <string.h> -#include <stdio.h> -#include <sys/time.h> #include "pinyin_internal.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; diff --git a/tests/storage/test_pinyin_index.cpp b/tests/storage/test_pinyin_index.cpp index 2a945f4..64e926d 100644 --- a/tests/storage/test_pinyin_index.cpp +++ b/tests/storage/test_pinyin_index.cpp @@ -1,28 +1,9 @@ +#include "timer.h" #include <string.h> -#include <stdio.h> -#include <sys/time.h> #include "pinyin_internal.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[]){ PinyinCustomSettings custom; |