Skip to content

Commit

Permalink
Merge pull request #26 from raj-prince/rand_read_monitor_block_latency
Browse files Browse the repository at this point in the history
feat: capturing range-read latency for random read
  • Loading branch information
raj-prince authored Nov 10, 2024
2 parents 4328e8d + 49a6cc5 commit 381c297
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions benchmark-script/read_operation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func randReadAlreadyOpenedFile(index int) (err error) {
pattern := getRandReadPattern()
b := make([]byte, *fBlockSizeKB*1024)
for i := 0; i < *fNumberOfRead; i++ {
readStart := time.Now()

for j := 0; j < len(pattern); j++ {
offset := pattern[j]

readStart := time.Now()
_, _ = fileHandles[index].Seek(offset, 0)

_, err = fileHandles[index].Read(b)
Expand All @@ -114,16 +114,16 @@ func randReadAlreadyOpenedFile(index int) (err error) {
} else {
err = nil
}

readLatency := time.Since(readStart)
throughput := float64((*fBlockSizeKB) / 1024) / readLatency.Seconds()
gResult.Append(readLatency.Seconds(), throughput)

}

if err != nil {
return fmt.Errorf("while reading and discarding content: %v", err)
}

readLatency := time.Since(readStart)

throughput := float64(*fFileSizeMB) / readLatency.Seconds()
gResult.Append(readLatency.Seconds(), throughput)
}
return
}
Expand Down Expand Up @@ -202,7 +202,8 @@ func main() {
if *fOutputDir == "" {
*fOutputDir, _ = os.Getwd()
}
gResult.DumpMetricsCSV(path.Join(*fOutputDir, "metrics.csv"))
csvFileName := "metrics_" + *fReadType + ".csv"
gResult.DumpMetricsCSV(path.Join(*fOutputDir, csvFileName))
gResult.PrintStats()

}

0 comments on commit 381c297

Please sign in to comment.