From 58d6cbcb3f7700b487ef90367c97480fff77a7b3 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 31 Aug 2024 15:41:06 +0200 Subject: [PATCH] Sort indices before writing, should be faster --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index 1e65dcb..ab6f695 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "io" "log" "os" + "sort" "sync" "time" @@ -73,6 +74,7 @@ func main() { toCorrupt := int64(float32(filesize) * (float32(*percent) / 100)) indicesToCorrupt := selectRandomIndices(filesize, toCorrupt) + sort.Slice(indicesToCorrupt, func(i, j int) bool { return indicesToCorrupt[i] < indicesToCorrupt[j] }) log.Printf("Corrupting %d bytes in %s", toCorrupt, file) for _, index := range indicesToCorrupt {