forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext_bench_test.go
42 lines (30 loc) · 944 Bytes
/
context_bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package types_test
import (
"testing"
"cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
)
func BenchmarkContext_KVStore(b *testing.B) {
key := types.NewKVStoreKey(b.Name() + "_TestCacheContext")
ctx := testutil.DefaultContext(key, types.NewTransientStoreKey("transient_"+b.Name()))
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = ctx.KVStore(key)
}
}
func BenchmarkContext_TransientStore(b *testing.B) {
key := types.NewKVStoreKey(b.Name() + "_TestCacheContext")
ctx := testutil.DefaultContext(key, types.NewTransientStoreKey("transient_"+b.Name()))
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = ctx.TransientStore(key)
}
}
func BenchmarkContext_CacheContext(b *testing.B) {
key := types.NewKVStoreKey(b.Name() + "_TestCacheContext")
ctx := testutil.DefaultContext(key, types.NewTransientStoreKey("transient_"+b.Name()))
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = ctx.CacheContext()
}
}