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

Function increment

dgraph/cmd/increment/increment_test.go:54–77  ·  view source on GitHub ↗
(t *testing.T, dg *dgo.Dgraph)

Source from the content-addressed store, hash-verified

52}
53
54func increment(t *testing.T, dg *dgo.Dgraph) int {
55 var max int
56 var mu sync.Mutex
57 storeMax := func(a int) {
58 mu.Lock()
59 if max < a {
60 max = a
61 }
62 mu.Unlock()
63 }
64
65 var wg sync.WaitGroup
66 // N goroutines, process N times each goroutine.
67 for i := 0; i < N; i++ {
68 wg.Add(1)
69 go func() {
70 defer wg.Done()
71 max := incrementInLoop(t, dg, N)
72 storeMax(max)
73 }()
74 }
75 wg.Wait()
76 return max
77}
78
79func read(t *testing.T, dg *dgo.Dgraph, expected int) {
80 conf := viper.New()

Callers 1

TestIncrementFunction · 0.85

Calls 6

incrementInLoopFunction · 0.85
WaitMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45
AddMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected