- querylog: remove time counter (fix zero div exception)

This commit is contained in:
Simon Zolin 2019-11-25 13:40:27 +03:00
parent 0a09c7eb4d
commit 305df63054
1 changed files with 12 additions and 5 deletions

View File

@ -172,7 +172,7 @@ type Reader struct {
fpos uint64 // current file offset fpos uint64 // current file offset
nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count) nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count)
timecnt uint64 // timecnt uint64
} }
type fileSeeker struct { type fileSeeker struct {
@ -205,8 +205,15 @@ func (r *Reader) Close() {
if r.count > 0 { if r.count > 0 {
perunit = elapsed / time.Duration(r.count) perunit = elapsed / time.Duration(r.count)
} }
log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)", log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d",
r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds())) r.count, elapsed, perunit, r.nSeekRequests)
// timePercent := uint64(0)
// if elapsed.Nanoseconds() != 0 {
// timePercent = r.timecnt * 100 / uint64(elapsed.Nanoseconds())
// }
// log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
// r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, timePercent)
if r.f != nil { if r.f != nil {
r.f.Close() r.f.Close()
@ -717,10 +724,10 @@ func (r *Reader) Next() *logEntry { // nolint
continue continue
} }
st := time.Now() // st := time.Now()
var ent logEntry var ent logEntry
decode(&ent, str) decode(&ent, str)
r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) // r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
return &ent return &ent
} }