| 516 | } |
| 517 | |
| 518 | func runReadsSequentialNested(cmd *cobra.Command, db *bolt.DB, options *benchOptions, results *benchResults) error { |
| 519 | return db.View(func(tx *bolt.Tx) error { |
| 520 | t := time.Now() |
| 521 | |
| 522 | for { |
| 523 | numReads := int64(0) |
| 524 | var top = tx.Bucket(benchBucketName) |
| 525 | if err := top.ForEach(func(name, _ []byte) error { |
| 526 | defer func() { results.addCompletedOps(numReads) }() |
| 527 | if b := top.Bucket(name); b != nil { |
| 528 | c := b.Cursor() |
| 529 | for k, v := c.First(); k != nil; k, v = c.Next() { |
| 530 | numReads++ |
| 531 | if v == nil { |
| 532 | return ErrInvalidValue |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | return nil |
| 537 | }); err != nil { |
| 538 | return err |
| 539 | } |
| 540 | |
| 541 | if options.writeMode == "seq-nest" && numReads != options.iterations { |
| 542 | return fmt.Errorf("read seq-nest: iter mismatch: expected %d, got %d", options.iterations, numReads) |
| 543 | } |
| 544 | |
| 545 | // Make sure we do this for at least a second. |
| 546 | if time.Since(t) >= time.Second { |
| 547 | break |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | return nil |
| 552 | }) |
| 553 | } |
| 554 | |
| 555 | func runReadsRandomNested(cmd *cobra.Command, db *bolt.DB, options *benchOptions, nestedKeys []nestedKey, results *benchResults) error { |
| 556 | return db.View(func(tx *bolt.Tx) error { |