Display analysis speed in positions/second

This commit is contained in:
Trevor Slocum 2024-11-22 22:44:36 -08:00
parent 2be040d10c
commit a9529056c6
2 changed files with 10 additions and 1 deletions

View file

@ -125,6 +125,7 @@ func (a *Analysis) _analyze() {
chance: check[2],
result: a.result,
resultMutex: a.resultMutex,
evaluated: 1,
}
bc.evaluate(a.player, 0, a)
a.resultMutex.Lock()

10
bei.go
View file

@ -68,8 +68,16 @@ func (s *BEIServer) handleConnection(conn net.Conn) {
}
analyzedPositions := b.Analyze(available, &analysis, false)
if s.Verbose {
var speed string
delta := time.Since(t)
log.Println(msgPrinter.Sprintf("Analyzed %d positions in %s. (%d/ms)", analyzedPositions, delta.Round(time.Millisecond), analyzedPositions/int(delta.Milliseconds())))
if delta.Nanoseconds() == 0 {
speed = "inf"
} else {
perNanosecond := float64(analyzedPositions) / float64(delta.Nanoseconds())
perSecond := int64(perNanosecond * 1000000000)
speed = msgPrinter.Sprintf("%d", perSecond)
}
log.Println(msgPrinter.Sprintf("Analyzed %d positions in %s. (%s/s)", analyzedPositions, delta.Round(time.Millisecond), speed))
}
var move *bei.Move
if len(analysis) > 0 {