Documentation
¶
Overview ¶
Package bench implements concurrent benchmark for cache backends.
Index ¶
- Constants
- Variables
- func Concurrently(b *testing.B, scenarios []Scenario)
- func StableHeapInUse() int64
- type FailoverOf
- type FailoverRunner
- type MutexMap
- type RWMutexMap
- type ReadWriterOfRunner
- type ReadWriterRunner
- type Runner
- type Scenario
- type ShardedMapBaseline
- type ShardedMapOfBaseline
- type SmallCachedValue
- type SyncMapBaseline
Constants ¶
const ( LongString = "looooooooooooooooooooooooooongstring" KeyPrefix = "thekey" )
Sample values.
Variables ¶
var ( Failovers = []Runner{ FailoverRunner{F: func() cache.ReadWriter { return cache.NewShardedMap() }}, FailoverRunner{F: func() cache.ReadWriter { return cache.NewSyncMap() }}, } Baseline = []Runner{ SyncMapBaseline{}, ShardedMapBaseline{}, &MutexMap{}, &RWMutexMap{}, } ReadWriters = []Runner{ ReadWriterRunner{F: func() cache.ReadWriter { return cache.NewShardedMap() }}, ReadWriterRunner{F: func() cache.ReadWriter { return cache.NewSyncMap() }}, } )
Default runners.
Functions ¶
func Concurrently ¶
Concurrently runs benchmarks concurrently.
func StableHeapInUse ¶
func StableHeapInUse() int64
StableHeapInUse attempts to determine heap in use when new allocations are reduced.
Types ¶
type FailoverOf ¶
type FailoverOf struct {
F func() cache.ReadWriterOf[SmallCachedValue]
C *cache.FailoverOf[SmallCachedValue]
D cache.Deleter
Cardinality int
}
FailoverOf is a benchmark runner.
type FailoverRunner ¶
type FailoverRunner struct {
F func() cache.ReadWriter
C *cache.Failover
D cache.Deleter
Cardinality int
}
FailoverRunner is a benchmark runner.
type MutexMap ¶
type MutexMap struct {
// contains filtered or unexported fields
}
MutexMap is a benchmark runner.
type RWMutexMap ¶
type RWMutexMap struct {
// contains filtered or unexported fields
}
RWMutexMap is a benchmark runner.
type ReadWriterOfRunner ¶
type ReadWriterOfRunner struct {
F func() cache.ReadWriterOf[SmallCachedValue]
RW cache.ReadWriterOf[SmallCachedValue]
D cache.Deleter
Cardinality int
}
ReadWriterOfRunner creates benchmark runner from cache.ReadWriterOf.
type ReadWriterRunner ¶
type ReadWriterRunner struct {
F func() cache.ReadWriter
RW cache.ReadWriter
D cache.Deleter
Cardinality int
}
ReadWriterRunner is a benchmark runner.
type Runner ¶
type Runner interface {
Make(b *testing.B, cardinality int) (Runner, string)
Run(b *testing.B, cnt int, writeEvery int)
}
Runner describes cache benchmark runner.
type ShardedMapBaseline ¶
type ShardedMapBaseline struct {
// contains filtered or unexported fields
}
ShardedMapBaseline is a benchmark runner.
type ShardedMapOfBaseline ¶
type ShardedMapOfBaseline struct {
// contains filtered or unexported fields
}
ShardedMapOfBaseline is a benchmark runner.
type SmallCachedValue ¶
SmallCachedValue represents a small value for a cached item.
func MakeCachedValue ¶
func MakeCachedValue(i int) SmallCachedValue
MakeCachedValue creates a SmallCachedValue.
func (SmallCachedValue) MarshalBinary ¶
func (s SmallCachedValue) MarshalBinary() (data []byte, err error)
MarshalBinary encodes SmallCachedValue to bytes.
func (*SmallCachedValue) UnmarshalBinary ¶
func (s *SmallCachedValue) UnmarshalBinary(data []byte) error
UnmarshalBinary loads value from bytes.
type SyncMapBaseline ¶
type SyncMapBaseline struct {
// contains filtered or unexported fields
}
SyncMapBaseline is a benchmark runner.