fix: speed up OBD tests avoid unnecessary memory allocation (#10141)

replace dummy buffer with nullReader{} instead,
to avoid large memory allocations in memory
constrainted environments. allows running
obd tests in such environments.
This commit is contained in:
Harshavardhana
2020-07-27 14:51:59 -07:00
committed by GitHub
parent 98691f75bc
commit f200a7fb6a
2 changed files with 27 additions and 37 deletions

View File

@@ -65,13 +65,6 @@ func GetOBDInfo(ctx context.Context, drive, fsPath string) (Latency, Throughput,
os.Remove(fsPath)
}()
// going to leave this here incase we decide to go back to caching again
// if gl, ok := globalLatency[drive]; ok {
// if gt, ok := globalThroughput[drive]; ok {
// return gl, gt, nil
// }
// }
blockSize := 4 * humanize.MiByte
fileSize := 256 * humanize.MiByte
@@ -94,6 +87,9 @@ func GetOBDInfo(ctx context.Context, drive, fsPath string) (Latency, Throughput,
latencies[i] = float64(latencyInSecs)
}
// Sync every full writes fdatasync
Fdatasync(w)
for i := range latencies {
throughput := float64(blockSize) / latencies[i]
throughputs[i] = throughput