fix: move verification time logging outside loop and only record average

This commit is contained in:
Derrick Hammer 2024-02-28 12:41:03 -05:00
parent 0b000bfc89
commit dd9fdabf47
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 2 deletions

View File

@ -68,8 +68,6 @@ func (v *Verifier) Read(p []byte) (int, error) {
timeEnd := time.Now()
v.verifyTime += timeEnd.Sub(timeStart)
averageVerifyTime := v.verifyTime / time.Duration(v.read/VERIFY_CHUNK_SIZE)
v.logger.Debug("Verification time", zap.Duration("duration", timeEnd.Sub(timeStart)), zap.Duration("average", averageVerifyTime))
if err == io.EOF {
// If EOF, break the loop as no more data can be read
@ -77,6 +75,9 @@ func (v *Verifier) Read(p []byte) (int, error) {
}
}
averageVerifyTime := v.verifyTime / time.Duration(v.read/VERIFY_CHUNK_SIZE)
v.logger.Debug("Verification time", zap.Duration("average", averageVerifyTime))
// Attempt to read the remainder of the data from the buffer
additionalBytes, _ := v.buffer.Read(p[n:])
return n + additionalBytes, nil