mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
in the speed test: initialize first to ignore the time of dict loading
This commit is contained in:
parent
bc049090a5
commit
d3339633d5
@ -3,6 +3,7 @@ import sys,time
|
|||||||
import sys
|
import sys
|
||||||
sys.path.append("../")
|
sys.path.append("../")
|
||||||
import jieba
|
import jieba
|
||||||
|
jieba.initialize()
|
||||||
|
|
||||||
url = sys.argv[1]
|
url = sys.argv[1]
|
||||||
content = open(url,"rb").read()
|
content = open(url,"rb").read()
|
||||||
@ -14,7 +15,7 @@ tm_cost = t2-t1
|
|||||||
|
|
||||||
log_f = open("1.log","wb")
|
log_f = open("1.log","wb")
|
||||||
for w in words:
|
for w in words:
|
||||||
print >> log_f, w.encode("gbk"), "/" ,
|
print >> log_f, w.encode("utf-8"), "/" ,
|
||||||
print 'cost',tm_cost
|
print 'cost',tm_cost
|
||||||
print 'speed' , len(content)/tm_cost, " bytes/second"
|
print 'speed' , len(content)/tm_cost, " bytes/second"
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ import urllib2
|
|||||||
import sys,time
|
import sys,time
|
||||||
import sys
|
import sys
|
||||||
sys.path.append("../")
|
sys.path.append("../")
|
||||||
|
import jieba
|
||||||
|
jieba.initialize()
|
||||||
import jieba.posseg as pseg
|
import jieba.posseg as pseg
|
||||||
|
|
||||||
url = sys.argv[1]
|
url = sys.argv[1]
|
||||||
@ -14,7 +16,7 @@ tm_cost = t2-t1
|
|||||||
|
|
||||||
log_f = open("1.log","wb")
|
log_f = open("1.log","wb")
|
||||||
for w in words:
|
for w in words:
|
||||||
print >> log_f, w.encode("gbk"), "/" ,
|
print >> log_f, w.encode("utf-8"), "/" ,
|
||||||
|
|
||||||
print 'speed' , len(content)/tm_cost, " bytes/second"
|
print 'speed' , len(content)/tm_cost, " bytes/second"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user