From dd9fdabf479faa3bf101f59bbcebe3b7f6498d04 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 28 Feb 2024 12:41:03 -0500 Subject: [PATCH] fix: move verification time logging outside loop and only record average --- bao/bao.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bao/bao.go b/bao/bao.go index 916a76d..4eda1ed 100644 --- a/bao/bao.go +++ b/bao/bao.go @@ -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