From c34f5d50a1fdf4015d97dd1dba15657b5755ff44 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 1 Dec 2011 15:40:26 +0800 Subject: update test cases --- tests/lookup/test_simple_lookup.cpp | 7 +++---- tests/storage/test_parser2.cpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/lookup/test_simple_lookup.cpp b/tests/lookup/test_simple_lookup.cpp index 7fefa99..dad9ddd 100644 --- a/tests/lookup/test_simple_lookup.cpp +++ b/tests/lookup/test_simple_lookup.cpp @@ -2,7 +2,7 @@ #include #include "pinyin_internal.h" -size_t bench_times = 1000; +size_t bench_times = 100; int main( int argc, char * argv[]){ @@ -66,10 +66,9 @@ int main( int argc, char * argv[]){ MatchResults results = g_array_new(FALSE, FALSE, sizeof(phrase_token_t)); guint32 start_time = record_time(); - size_t times = 100; - for ( size_t i = 0; i < times; ++i) + for ( size_t i = 0; i < bench_times; ++i) pinyin_lookup.get_best_match(keys, constraints, results); - print_time(start_time, times); + print_time(start_time, bench_times); for ( size_t i = 0; i < results->len; ++i){ phrase_token_t * token = &g_array_index(results, phrase_token_t, i); if ( null_token == *token) diff --git a/tests/storage/test_parser2.cpp b/tests/storage/test_parser2.cpp index 2ba2511..3748338 100644 --- a/tests/storage/test_parser2.cpp +++ b/tests/storage/test_parser2.cpp @@ -20,6 +20,7 @@ */ +#include "timer.h" #include #include #include @@ -28,6 +29,8 @@ #include "pinyin_parser2.h" +size_t bench_times = 1000; + using namespace pinyin; static const char * help_msg = @@ -107,8 +110,14 @@ int main(int argc, char * argv[]) { #endif #if 1 - int len = parser->parse(options, keys, key_rests, + int len = 0; + guint32 start_time = record_time(); + for ( size_t i = 0; i < bench_times; ++i) + len = parser->parse(options, keys, key_rests, linebuf, strlen(linebuf)); + + print_time(start_time, bench_times); + printf("parsed %d chars, %d keys.\n", len, keys->len); assert(keys->len == key_rests->len); -- cgit