MCPcopy
hub / github.com/etcd-io/bbolt / runReadsSequentialNested

Function runReadsSequentialNested

cmd/bbolt/command/command_bench.go:518–553  ·  view source on GitHub ↗
(cmd *cobra.Command, db *bolt.DB, options *benchOptions, results *benchResults)

Source from the content-addressed store, hash-verified

516}
517
518func 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
555func runReadsRandomNested(cmd *cobra.Command, db *bolt.DB, options *benchOptions, nestedKeys []nestedKey, results *benchResults) error {
556 return db.View(func(tx *bolt.Tx) error {

Callers 1

runReadsFunction · 0.85

Calls 8

ViewMethod · 0.80
addCompletedOpsMethod · 0.80
FirstMethod · 0.80
NextMethod · 0.80
ErrorfMethod · 0.65
BucketMethod · 0.45
ForEachMethod · 0.45
CursorMethod · 0.45

Tested by

no test coverage detected