adjusted target size for faster result

This commit is contained in:
Suyono 2024-06-26 19:02:21 +10:00
parent 9b94acad71
commit 90c50b9d85

View File

@ -209,9 +209,10 @@ func createWriteAndDelete(ctx context.Context, sm *sync.Map, initialWait time.Du
err error err error
currLen int64 currLen int64
wLen int wLen int
targetLen int64
) )
targetLen := rand.Int63n(1024*1024) + 102400 targetLen = 2 * 102400
nextFile = genUniqueRandomString(sm, 6) nextFile = genUniqueRandomString(sm, 6)
nextFileName = nextFile + ".txt" nextFileName = nextFile + ".txt"
@ -235,8 +236,8 @@ func createWriteAndDelete(ctx context.Context, sm *sync.Map, initialWait time.Du
_ = os.Remove(nextFileName) _ = os.Remove(nextFileName)
return return
} }
log.Printf("written %d bytes to %s\n", wLen, nextFileName)
currLen += int64(wLen) currLen += int64(wLen)
log.Printf("written %d of %d bytes to %s\n", currLen, targetLen, nextFileName)
if currLen > targetLen { if currLen > targetLen {
_ = f.Close() _ = f.Close()
next = deleteFile next = deleteFile