Source file
test/fixedbugs/issue16008.go
1
2
3
4
5
6
7
8
9 package foo
10
11 const benchmarkNumNodes = 10000
12
13 func BenchmarkUpdateNodeTransaction(b B) {
14 s, nodeIDs := setupNodes(benchmarkNumNodes)
15 b.ResetTimer()
16 for i := 0; i < b.N(); i++ {
17 _ = s.Update(func(tx1 Tx) error {
18 _ = UpdateNode(tx1, &Node{
19 ID: nodeIDs[i%benchmarkNumNodes],
20 })
21 return nil
22 })
23 }
24 }
25
26 type B interface {
27 ResetTimer()
28 N() int
29 }
30
31 type Tx interface {
32 }
33
34 type Node struct {
35 ID string
36 }
37
38 type MemoryStore struct {
39 }
40
41
42 func setupNodes(n int) (s *MemoryStore, nodeIDs []string) {
43 return
44 }
45
46
47 func (s *MemoryStore) Update(cb func(Tx) error) error {
48 return nil
49 }
50
51 var sink interface{}
52
53
54 func UpdateNode(tx Tx, n *Node) error {
55 sink = tx
56 sink = n
57 return nil
58 }
59
View as plain text