Exemplo n.º 1
0
func BenchmarkGet(b *testing.B) {
	b.StopTimer()
	if benchDb == nil {
		benchDb = newTestDb(true, 0)
		benchDb.Execute(NewTransaction(func(b *TransactionBlock) {
			b.Set("test_container", "benchget", "somevalue")
		}))
	}
	b.StartTimer()

	for i := 0; i < b.N; i++ {
		ret := benchDb.Execute(NewTransaction(func(b *TransactionBlock) {
			b.Return(b.Get("test_container", "benchget"))
		}))

		if ret.Error != nil {
			fmt.Errorf("Got an error during benchmark: %v", *ret.Error.Message)
		}
	}
}