当前位置: 首页>>代码示例>>Golang>>正文


Golang api.StoredMap类代码示例

本文整理汇总了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++
		}
	})
}
开发者ID:jenchik,项目名称:stored,代码行数:26,代码来源:benchmark.go

示例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)
		})
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:10,代码来源:benchmark.go

示例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)
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:11,代码来源:benchmark.go

示例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)
		}
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:13,代码来源:benchmark.go

示例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)
		})
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:14,代码来源:benchmark.go

示例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)
			}
		})
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:15,代码来源:benchmark.go

示例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++
		}
	})
}
开发者ID:jenchik,项目名称:stored,代码行数:16,代码来源:benchmark.go

示例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++
		}
	})
}
开发者ID:jenchik,项目名称:stored,代码行数:16,代码来源:benchmark.go

示例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)
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:17,代码来源:benchmark.go

示例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++
		}
	})
}
开发者ID:jenchik,项目名称:stored,代码行数:18,代码来源:benchmark.go

示例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)
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:19,代码来源:benchmark.go

示例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++
		}
	})
}
开发者ID:jenchik,项目名称:stored,代码行数:19,代码来源:benchmark.go

示例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)
	}
}
开发者ID:jenchik,项目名称:stored,代码行数:21,代码来源:benchmark.go

示例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++
		}
	})
}
开发者ID:jenchik,项目名称:stored,代码行数:24,代码来源:benchmark.go

示例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
	})
}
开发者ID:jenchik,项目名称:stored,代码行数:6,代码来源:hugemap_test.go


注:本文中的github.com/jenchik/stored/api.StoredMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。