MCPcopy
hub / github.com/dgraph-io/dgraph / BenchmarkTestCache

Function BenchmarkTestCache

posting/mvcc_test.go:95–145  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

93}
94
95func BenchmarkTestCache(b *testing.B) {
96 dir, err := os.MkdirTemp("", "storetest_")
97 x.Panic(err)
98 defer os.RemoveAll(dir)
99
100 ps, err = badger.OpenManaged(badger.DefaultOptions(dir))
101 x.Panic(err)
102 Init(ps, 10000000, true)
103 schema.Init(ps)
104
105 attr := x.AttrInRootNamespace("cache")
106 keys := make([][]byte, 0)
107 N := uint64(10000)
108 NInt := 10000
109 txn := Oracle().RegisterStartTs(1)
110
111 for i := uint64(1); i < N; i++ {
112 key := x.DataKey(attr, i)
113 keys = append(keys, key)
114 edge := &pb.DirectedEdge{
115 ValueId: 2,
116 Attr: attr,
117 Entity: 1,
118 Op: pb.DirectedEdge_SET,
119 }
120 l, _ := GetNoStore(key, 1)
121 // No index entries added here as we do not call AddMutationWithIndex.
122 txn.cache.SetIfAbsent(string(l.key), l)
123 err := l.addMutation(context.Background(), txn, edge)
124 if err != nil {
125 panic(err)
126 }
127 }
128 txn.Update()
129 writer := NewTxnWriter(pstore)
130 err = txn.CommitToDisk(writer, 2)
131 if err != nil {
132 panic(err)
133 }
134 writer.Flush()
135
136 b.RunParallel(func(pb *testing.PB) {
137 for pb.Next() {
138 key := keys[rand.Intn(NInt-1)]
139 _, err = getNew(key, pstore, math.MaxUint64, false)
140 if err != nil {
141 panic(err)
142 }
143 }
144 })
145}
146
147func TestRollupTimestamp(t *testing.T) {
148 attr := x.AttrInRootNamespace("rollup")

Callers

nothing calls this directly

Calls 15

FlushMethod · 0.95
PanicFunction · 0.92
InitFunction · 0.92
AttrInRootNamespaceFunction · 0.92
DataKeyFunction · 0.92
GetNoStoreFunction · 0.85
NewTxnWriterFunction · 0.85
getNewFunction · 0.85
RemoveAllMethod · 0.80
RegisterStartTsMethod · 0.80
SetIfAbsentMethod · 0.80
addMutationMethod · 0.80

Tested by

no test coverage detected