summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-12-01 15:40:26 +0800
committerPeng Wu <alexepico@gmail.com>2011-12-01 15:40:26 +0800
commitc34f5d50a1fdf4015d97dd1dba15657b5755ff44 (patch)
tree415f37332b89c40b9bea17afecb79967617b8d09 /tests
parent3d95277dff2e91ce436874bee5e51315f7fc4462 (diff)
downloadlibpinyin-c34f5d50a1fdf4015d97dd1dba15657b5755ff44.tar.gz
libpinyin-c34f5d50a1fdf4015d97dd1dba15657b5755ff44.tar.xz
libpinyin-c34f5d50a1fdf4015d97dd1dba15657b5755ff44.zip
update test cases
Diffstat (limited to 'tests')
-rw-r--r--tests/lookup/test_simple_lookup.cpp7
-rw-r--r--tests/storage/test_parser2.cpp11
2 files changed, 13 insertions, 5 deletions
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 <string.h>
#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 <errno.h>
#include <stdio.h>
#include <assert.h>
@@ -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);