Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LevelDBBenchCmd = &cobra.Command{ Use: "leveldbbench [flags]", Short: "Perform a level db benchmark", Long: usage, RunE: func(cmd *cobra.Command, args []string) error { log.Info().Msg("Starting level db test") db, err := leveldb.OpenFile(*dbPath, &opt.Options{ Filter: filter.NewBloomFilter(10), DisableSeeksCompaction: true, OpenFilesCacheCapacity: *openFilesCacheCapacity, BlockCacheCapacity: *cacheSize / 2 * opt.MiB, WriteBuffer: *cacheSize / 4 * opt.MiB, ReadOnly: *readOnly || *fullScan, }) if err != nil { return err } ctx := context.Background() wo := opt.WriteOptions{ NoWriteMerge: *noWriteMerge, Sync: *syncWrites, } ro := &opt.ReadOptions{ DontFillCache: *dontFillCache, } if *readStrict { ro.Strict = opt.StrictAll } else { ro.Strict = opt.DefaultStrict } if *nilReadOptions { ro = nil } var start time.Time trs := make([]*TestResult, 0) sequentialWritesDesc := "random" if *sequentialWrites { sequentialWritesDesc = "sequential" } sequentialReadsDesc := "random" if *sequentialReads { sequentialReadsDesc = "sequential" } if *fullScan { start = time.Now() opCount, valueDist := runFullScan(ctx, db, &wo, ro) tr := NewTestResult(start, time.Now(), "full scan", opCount, db) tr.ValueDist = valueDist trs = append(trs, tr) return printSummary(trs) } if !*readOnly { start = time.Now() writeData(ctx, db, &wo, 0, *writeLimit, *sequentialWrites) trs = append(trs, NewTestResult(start, time.Now(), fmt.Sprintf("initial %s write", sequentialWritesDesc), *writeLimit, db)) for i := 0; i < int(*overwriteCount); i += 1 { start = time.Now() writeData(ctx, db, &wo, 0, *writeLimit, *sequentialWrites) trs = append(trs, NewTestResult(start, time.Now(), fmt.Sprintf("%s overwrite %d", sequentialWritesDesc, i), *writeLimit, db)) } start = time.Now() runFullCompact(ctx, db, &wo) trs = append(trs, NewTestResult(start, time.Now(), "compaction", 1, db)) } if *sequentialReads { start = time.Now() readSeq(ctx, db, &wo, *readLimit) trs = append(trs, NewTestResult(start, time.Now(), fmt.Sprintf("%s read", sequentialReadsDesc), *readLimit, db)) } else { start = time.Now() readRandom(ctx, db, ro, *readLimit) trs = append(trs, NewTestResult(start, time.Now(), fmt.Sprintf("%s read", sequentialWritesDesc), *readLimit, db)) } log.Info().Msg("Close DB") err = db.Close() if err != nil { log.Error().Err(err).Msg("Error while closing db") } return printSummary(trs) }, Args: func(cmd *cobra.Command, args []string) error { var err error sizeDistribution, err = parseRawSizeDistribution(*rawSizeDistribution) if err != nil { return err } if *keySize > 64 { return fmt.Errorf(" max supported key size is 64 bytes. %d is too big", *keySize) } return nil }, }
Functions ¶
This section is empty.
Types ¶
type IODistribution ¶
type IODistribution struct {
// contains filtered or unexported fields
}
func NewIODistribution ¶
func NewIODistribution(ranges []IORange) (*IODistribution, error)
func (*IODistribution) GetSizeSample ¶
func (i *IODistribution) GetSizeSample() uint64
GetSizeSample will return an IO size in accordance with the probability distribution
type LoadTestOperation ¶
type LoadTestOperation int
type RandomKeySeeker ¶
type RandomKeySeeker struct {
// contains filtered or unexported fields
}
func NewRandomKeySeeker ¶
func NewRandomKeySeeker(db *leveldb.DB) *RandomKeySeeker
func (*RandomKeySeeker) Key ¶
func (r *RandomKeySeeker) Key() []byte
Click to show internal directories.
Click to hide internal directories.