Skip to content

Commit

Permalink
测试SmartBinTrie
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Nov 1, 2014
1 parent 259de51 commit e971d44
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package com.hankcs.hanlp.collection.trie.bintrie;

/**
* 可以动态拓展为hash定位的trie树,适用于词典特别大且插入删除操作特别多的场景
* @author hankcs
*/
public class SmartBinTrie<V> extends BinTrie<V>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.hankcs.hanlp.collection.trie.bintrie.util.ArrayTool;

/**
* 可以动态拓展为hash定位的trie树节点,适用于词典特别大且插入删除操作特别多的场景
* @author hankcs
*/
public class SmartNode<V> extends BaseNode<V>
Expand Down
18 changes: 16 additions & 2 deletions test/java/com/hankcs/test/seg/testBintrie.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,28 @@ public void testSmartVsNormal() throws Exception
{
trieNormal.put(word, word);
}
System.out.printf("trieNormal插入耗时:%dms%n", System.currentTimeMillis() - start);
System.out.printf("trieNormal首次插入耗时:%dms%n", System.currentTimeMillis() - start);

start = System.currentTimeMillis();
for (String word : wordList)
{
trieSmart.put(word, word);
}
System.out.printf("trieSmart插入耗时:%dms%n", System.currentTimeMillis() - start);
System.out.printf("trieSmart首次插入耗时:%dms%n", System.currentTimeMillis() - start);

start = System.currentTimeMillis();
for (String word : wordList)
{
trieNormal.put(word, word);
}
System.out.printf("trieNormal再次插入耗时:%dms%n", System.currentTimeMillis() - start);

start = System.currentTimeMillis();
for (String word : wordList)
{
trieSmart.put(word, word);
}
System.out.printf("trieSmart再次插入耗时:%dms%n", System.currentTimeMillis() - start);

start = System.currentTimeMillis();
for (String word : wordList)
Expand Down

0 comments on commit e971d44

Please sign in to comment.