本文整理汇总了Golang中github.com/jenchik/stored/api.StoredMap类的典型用法代码示例。如果您正苦于以下问题:Golang StoredMap类的具体用法?Golang StoredMap怎么用?Golang StoredMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StoredMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BThreadsAtomicComplex
func BThreadsAtomicComplex(b *testing.B, sm api.StoredMap) {
l := len(UniqKey)
inserter := func(key string) {
sm.Atomic(func(m api.Mapper) {
if value, found := m.Find(key); found {
_ = value.(string)
return
}
m.SetKey(key)
m.Update(key)
})
}
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var k string
var i int
for pb.Next() {
k = UniqKey[i%l]
inserter(k)
i++
}
})
}
示例2: BEachFullCicle
func BEachFullCicle(b *testing.B, sm api.StoredMap) {
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
sm.Each(func(m api.Mapper) {
_ = m.Value().(string)
})
}
}
示例3: BInsert
func BInsert(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
sm.Insert(k, k)
}
}
示例4: BFind
func BFind(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
if value, found := sm.Find(k); found {
_ = value.(string)
}
}
}
示例5: BAtomicWaitUpdate
func BAtomicWaitUpdate(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
sm.AtomicWait(func(m api.Mapper) {
m.SetKey(k)
m.Update(k)
})
}
}
示例6: BAtomicWaitFind
func BAtomicWaitFind(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
sm.AtomicWait(func(m api.Mapper) {
if value, found := m.Find(k); found {
_ = value.(string)
}
})
}
}
示例7: BThreadsDelete
func BThreadsDelete(b *testing.B, sm api.StoredMap) {
l := len(UniqKey)
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var k string
var i int
for pb.Next() {
k = UniqKey[i%l]
sm.Delete(k)
i++
}
})
}
示例8: BThreadsEachShort
func BThreadsEachShort(b *testing.B, sm api.StoredMap) {
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var i int
for pb.Next() {
sm.Each(func(m api.Mapper) {
_ = m.Value().(string)
m.Stop()
})
i++
}
})
}
示例9: BAtomicUpdate
func BAtomicUpdate(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
inserter := func(key string) {
sm.Atomic(func(m api.Mapper) {
m.SetKey(key)
m.Update(key)
})
}
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
inserter(k)
}
}
示例10: BThreadsFind
func BThreadsFind(b *testing.B, sm api.StoredMap) {
l := len(UniqKey)
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var k string
var i int
for pb.Next() {
k = UniqKey[i%l]
if value, found := sm.Find(k); found {
_ = value.(string)
}
i++
}
})
}
示例11: BUpdate
func BUpdate(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
updater := func(key string) {
sm.Update(key, func(value interface{}, found bool) interface{} {
if found {
_ = value.(string)
}
return key
})
}
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
updater(k)
}
}
示例12: BThreadsAtomicWaitUpdate
func BThreadsAtomicWaitUpdate(b *testing.B, sm api.StoredMap) {
l := len(UniqKey)
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var k string
var i int
for pb.Next() {
k = UniqKey[i%l]
sm.AtomicWait(func(m api.Mapper) {
m.SetKey(k)
m.Update(k)
})
i++
}
})
}
示例13: BAtomicComplex
func BAtomicComplex(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
inserter := func(key string) {
sm.Atomic(func(m api.Mapper) {
if value, found := m.Find(key); found {
_ = value.(string)
return
}
m.SetKey(key)
m.Update(key)
})
}
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
inserter(k)
}
}
示例14: BThreadsUpdate
func BThreadsUpdate(b *testing.B, sm api.StoredMap) {
l := len(UniqKey)
updater := func(key string) {
sm.Update(key, func(value interface{}, found bool) interface{} {
if found {
_ = value.(string)
}
return key
})
}
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var k string
var i int
for pb.Next() {
k = UniqKey[i%l]
updater(k)
i++
}
})
}
示例15: testUpdate
func testUpdate(sm api.StoredMap, t *test.Item, f func(string, bool)) {
sm.Update(t.K, func(value interface{}, found bool) interface{} {
f(t.K, found)
return t.V
})
}