func BenchmarkSet(b *testing.B) { b.StopTimer() if benchDb == nil { benchDb = newTestDb(true, 0) } b.StartTimer() for i := 0; i < b.N; i++ { trx := NewTransaction(func(b *TransactionBlock) { b.Set("test_container", "benchset", "salut 1.0") }) benchDb.Execute(trx) } }
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) } } }