Sort indices before writing, should be faster
This commit is contained in:
2
main.go
2
main.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ func main() {
|
|||||||
|
|
||||||
toCorrupt := int64(float32(filesize) * (float32(*percent) / 100))
|
toCorrupt := int64(float32(filesize) * (float32(*percent) / 100))
|
||||||
indicesToCorrupt := selectRandomIndices(filesize, toCorrupt)
|
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)
|
log.Printf("Corrupting %d bytes in %s", toCorrupt, file)
|
||||||
|
|
||||||
for _, index := range indicesToCorrupt {
|
for _, index := range indicesToCorrupt {
|
||||||
|
Reference in New Issue
Block a user