1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-08 18:40:24 +08:00

small tweaks, added bench.sh for benchmark

This commit is contained in:
Wang Bin
2015-04-04 15:26:26 +08:00
parent 8687ca58b8
commit 188133261f
2 changed files with 8 additions and 1 deletions

5
posseg/bench.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
go test -run=XXX -v -bench=BenchmarkViterbi -benchtime 10s -benchmem -memprofile viterbi-mem.out -cpuprofile viterbi-cpu.out
go tool pprof -png -output ~/tmp/viterbi-cpu.png posseg.test viterbi-cpu.out
go tool pprof -png -output ~/tmp/viterbi-mem.png posseg.test viterbi-mem.out

View File

@@ -4,13 +4,15 @@ import (
"math"
)
var inf = math.Inf(-1)
type probTransMap map[string]float64
func (m probTransMap) Get(key string) float64 {
if value, ok := m[key]; ok {
return value
} else {
return math.Inf(-1)
return inf
}
}