Browse Source

randomize the file size a little bit

pull/2/head
Chris Lu 11 years ago
parent
commit
2841d59fb0
  1. 5
      go/weed/benchmark.go

5
go/weed/benchmark.go

@ -161,7 +161,8 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stats) {
for { for {
if id, ok := <-idChan; ok { if id, ok := <-idChan; ok {
start := time.Now() start := time.Now()
fp := &operation.FilePart{Reader: &FakeReader{id: uint64(id), size: int64(*b.fileSize)}, FileSize: int64(*b.fileSize)}
fileSize := int64(*b.fileSize + rand.Intn(64))
fp := &operation.FilePart{Reader: &FakeReader{id: uint64(id), size: fileSize}, FileSize: fileSize}
if assignResult, err := operation.Assign(*b.server, 1, "", *b.collection); err == nil { if assignResult, err := operation.Assign(*b.server, 1, "", *b.collection); err == nil {
fp.Server, fp.Fid, fp.Collection = assignResult.PublicUrl, assignResult.Fid, *b.collection fp.Server, fp.Fid, fp.Collection = assignResult.PublicUrl, assignResult.Fid, *b.collection
if _, ok := serverLimitChan[fp.Server]; !ok { if _, ok := serverLimitChan[fp.Server]; !ok {
@ -171,7 +172,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stats) {
if _, err := fp.Upload(0, *b.server); err == nil { if _, err := fp.Upload(0, *b.server); err == nil {
fileIdLineChan <- fp.Fid fileIdLineChan <- fp.Fid
s.completed++ s.completed++
s.transferred += int64(*b.fileSize)
s.transferred += fileSize
} else { } else {
s.failed++ s.failed++
} }

Loading…
Cancel
Save