mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-18 20:57:49 +08:00
randomize benchmark content
fix https://github.com/chrislusf/seaweedfs/issues/1294
This commit is contained in:
parent
fb81f12686
commit
eab4c9219c
@ -227,7 +227,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stat) {
|
|||||||
start := time.Now()
|
start := time.Now()
|
||||||
fileSize := int64(*b.fileSize + random.Intn(64))
|
fileSize := int64(*b.fileSize + random.Intn(64))
|
||||||
fp := &operation.FilePart{
|
fp := &operation.FilePart{
|
||||||
Reader: &FakeReader{id: uint64(id), size: fileSize},
|
Reader: &FakeReader{id: uint64(id), size: fileSize, random: random},
|
||||||
FileSize: fileSize,
|
FileSize: fileSize,
|
||||||
MimeType: "image/bench", // prevent gzip benchmark content
|
MimeType: "image/bench", // prevent gzip benchmark content
|
||||||
}
|
}
|
||||||
@ -552,6 +552,7 @@ func (s *stats) printStats() {
|
|||||||
type FakeReader struct {
|
type FakeReader struct {
|
||||||
id uint64 // an id number
|
id uint64 // an id number
|
||||||
size int64 // max bytes
|
size int64 // max bytes
|
||||||
|
random *rand.Rand
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *FakeReader) Read(p []byte) (n int, err error) {
|
func (l *FakeReader) Read(p []byte) (n int, err error) {
|
||||||
@ -567,6 +568,7 @@ func (l *FakeReader) Read(p []byte) (n int, err error) {
|
|||||||
for i := 0; i < 8; i++ {
|
for i := 0; i < 8; i++ {
|
||||||
p[i] = byte(l.id >> uint(i*8))
|
p[i] = byte(l.id >> uint(i*8))
|
||||||
}
|
}
|
||||||
|
l.random.Read(p[8:])
|
||||||
}
|
}
|
||||||
l.size -= int64(n)
|
l.size -= int64(n)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user