Skip to content

Commit da18845

Browse files
authored
feat(storage): Specify benchmark integrity check. (googleapis#11465)
Allow the benchmark runner to specify the integrity check mode to use for uploads.
1 parent aa54375 commit da18845

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

storage/internal/benchmarks/benchmark_result.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ func (br *benchmarkResult) selectWriteParams(opts benchmarkOptions, api benchmar
8787
api = jsonAPI
8888
}
8989

90-
_, doMD5, doCRC32C := randomOf3()
90+
doMD5, doCRC32C := false, false
91+
switch opts.integrity {
92+
case crc32cIC:
93+
doCRC32C = true
94+
case md5IC:
95+
doMD5 = true
96+
case randomIC:
97+
_, doMD5, doCRC32C = randomOf3()
98+
}
9199
br.params = randomizedParams{
92100
appBufferSize: opts.writeBufferSize,
93101
chunkSize: randomInt64(opts.minChunkSize, opts.maxChunkSize),

storage/internal/benchmarks/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type benchmarkOptions struct {
6666
numSamples int
6767
numWorkers int
6868
api benchmarkAPI
69+
integrity benchmarkIC
6970

7071
objectSize int64
7172
minObjectSize int64
@@ -130,6 +131,7 @@ func (b *benchmarkOptions) String() string {
130131

131132
stringifiedOpts := []string{
132133
fmt.Sprintf("api:\t\t\t%s", b.api),
134+
fmt.Sprintf("interity check:\t\t%d", b.integrity),
133135
fmt.Sprintf("region:\t\t\t%s", b.region),
134136
fmt.Sprintf("timeout:\t\t%s", b.timeout),
135137
fmt.Sprintf("number of samples:\t%d", b.numSamples),
@@ -163,6 +165,7 @@ func parseFlags() {
163165
flag.IntVar(&opts.numSamples, "samples", 8000, "number of samples to report")
164166
flag.IntVar(&opts.numWorkers, "workers", 16, "number of concurrent workers")
165167
flag.StringVar((*string)(&opts.api), "api", string(mixedAPIs), "api used to upload/download objects; JSON or XML values will use JSON to uplaod and XML to download")
168+
flag.StringVar((*string)(&opts.integrity), "integrity", string(randomIC), "integrity check performed on uploads; crc32c, md5, none, or random (default) to randomly choose which to check on each upload")
166169

167170
objectRange := flag.String("object_size", fmt.Sprint(1024*kib), "object size in bytes")
168171

@@ -329,6 +332,15 @@ const (
329332
directPath benchmarkAPI = "DirectPath"
330333
)
331334

335+
type benchmarkIC string
336+
337+
const (
338+
crc32cIC benchmarkIC = "crc32c"
339+
md5IC benchmarkIC = "md5"
340+
noneIC benchmarkIC = "none"
341+
randomIC benchmarkIC = "random"
342+
)
343+
332344
func (api benchmarkAPI) validate() error {
333345
switch api {
334346
case jsonAPI, grpcAPI, xmlAPI, directPath, mixedAPIs:

0 commit comments

Comments
 (0)