(b *testing.B)
| 93 | } |
| 94 | |
| 95 | func 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 | |
| 147 | func TestRollupTimestamp(t *testing.T) { |
| 148 | attr := x.AttrInRootNamespace("rollup") |
nothing calls this directly
no test coverage detected