feat(storage): Specify benchmark integrity check. (#11465) · googleapis/google-cloud-go@da18845

@@ -66,6 +66,7 @@ type benchmarkOptions struct {

6666

numSamples int

6767

numWorkers int

6868

api benchmarkAPI

69+

integrity benchmarkIC

69707071

objectSize int64

7172

minObjectSize int64

@@ -130,6 +131,7 @@ func (b *benchmarkOptions) String() string {

130131131132

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")

166169167170

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

168171

@@ -329,6 +332,15 @@ const (

329332

directPath benchmarkAPI = "DirectPath"

330333

)

331334335+

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: