(cmd *cobra.Command, db *bolt.DB, options *benchOptions, results *benchResults, keys []nestedKey)
| 394 | } |
| 395 | |
| 396 | func runReads(cmd *cobra.Command, db *bolt.DB, options *benchOptions, results *benchResults, keys []nestedKey) error { |
| 397 | // Start profiling for reads. |
| 398 | if options.profileMode == "r" { |
| 399 | startProfiling(cmd, options) |
| 400 | } |
| 401 | |
| 402 | finishChan := make(chan interface{}) |
| 403 | go checkProgress(results, finishChan, cmd.ErrOrStderr()) |
| 404 | defer close(finishChan) |
| 405 | |
| 406 | t := time.Now() |
| 407 | |
| 408 | var err error |
| 409 | switch options.readMode { |
| 410 | case "seq": |
| 411 | switch options.writeMode { |
| 412 | case "seq-nest", "rnd-nest": |
| 413 | err = runReadsSequentialNested(cmd, db, options, results) |
| 414 | default: |
| 415 | err = runReadsSequential(cmd, db, options, results) |
| 416 | } |
| 417 | case "rnd": |
| 418 | switch options.writeMode { |
| 419 | case "seq-nest", "rnd-nest": |
| 420 | err = runReadsRandomNested(cmd, db, options, keys, results) |
| 421 | default: |
| 422 | err = runReadsRandom(cmd, db, options, keys, results) |
| 423 | } |
| 424 | default: |
| 425 | return fmt.Errorf("invalid read mode: %s", options.readMode) |
| 426 | } |
| 427 | |
| 428 | // Save read time. |
| 429 | results.setDuration(time.Since(t)) |
| 430 | |
| 431 | // Stop profiling for reads. |
| 432 | if options.profileMode == "rw" || options.profileMode == "r" { |
| 433 | stopProfiling(cmd) |
| 434 | } |
| 435 | |
| 436 | return err |
| 437 | } |
| 438 | |
| 439 | type nestedKey struct{ bucket, key []byte } |
| 440 |
no test coverage detected