summaryrefslogtreecommitdiffstats
path: root/tests/storage/test_chewing_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-16 14:18:15 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-16 14:18:15 +0800
commit6b86007755f0551e96c7d3796101e7889f5b4c3d (patch)
tree8b515aa7be928b87e48b9b5d3ee08b9b648aef17 /tests/storage/test_chewing_table.cpp
parent160a73b0d0efae72d2b6232e393897e3aa075811 (diff)
downloadlibpinyin-6b86007755f0551e96c7d3796101e7889f5b4c3d.zip
libpinyin-6b86007755f0551e96c7d3796101e7889f5b4c3d.tar.gz
libpinyin-6b86007755f0551e96c7d3796101e7889f5b4c3d.tar.xz
update test_chewing_table.cpp
Diffstat (limited to 'tests/storage/test_chewing_table.cpp')
-rw-r--r--tests/storage/test_chewing_table.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index ac09a10..a5d5bea 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -78,25 +78,19 @@ int main(int argc, char * argv[]) {
PhraseIndexRanges ranges;
memset(ranges, 0, sizeof(PhraseIndexRanges));
- guint8 min_index, max_index;
- phrase_index.get_sub_phrase_range(min_index, max_index);
-
- for (size_t i = min_index; i < max_index; ++i) {
- ranges[i] = g_array_new(FALSE, FALSE, sizeof(PhraseIndexRange));
- }
+ phrase_index.prepare_ranges(ranges);
for (size_t i = 0; i < bench_times; ++i) {
largetable.search(keys->len, (ChewingKey *)keys->data, ranges);
}
- for (size_t i = min_index; i < max_index; ++i) {
- g_array_set_size(ranges[i], 0);
- }
+ phrase_index.clear_ranges(ranges);
+
print_time(start, bench_times);
largetable.search(keys->len, (ChewingKey *)keys->data, ranges);
- for (size_t i = min_index; i < max_index; ++i) {
+ for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
GArray * & range = ranges[i];
if (range) {
if (range->len)
@@ -141,6 +135,8 @@ int main(int argc, char * argv[]) {
}
g_array_set_size(range, 0);
}
+
+ phrase_index.destroy_ranges(ranges);
g_array_free(keys, TRUE);
g_array_free(key_rests, TRUE);
}