MCPcopy
hub / github.com/openimsdk/open-im-server / TestSeq

Function TestSeq

pkg/common/storage/cache/redis/seq_conversation_test.go:37–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestSeq(t *testing.T) {
38 ts := newTestSeq()
39 var (
40 wg sync.WaitGroup
41 speed atomic.Int64
42 )
43
44 const count = 128
45 wg.Add(count)
46 for i := 0; i < count; i++ {
47 index := i + 1
48 go func() {
49 defer wg.Done()
50 var size int64 = 10
51 cID := strconv.Itoa(index * 1)
52 for i := 1; ; i++ {
53 //first, err := ts.mgo.Malloc(context.Background(), cID, size) // mongo
54 first, err := ts.Malloc(context.Background(), cID, size) // redis
55 if err != nil {
56 t.Logf("[%d-%d] %s %s", index, i, cID, err)
57 return
58 }
59 speed.Add(size)
60 _ = first
61 //t.Logf("[%d] %d -> %d", i, first+1, first+size)
62 }
63 }()
64 }
65
66 done := make(chan struct{})
67
68 go func() {
69 wg.Wait()
70 close(done)
71 }()
72
73 ticker := time.NewTicker(time.Second)
74
75 for {
76 select {
77 case <-done:
78 ticker.Stop()
79 return
80 case <-ticker.C:
81 value := speed.Swap(0)
82 t.Logf("speed: %d/s", value)
83 }
84 }
85}
86
87func TestDel(t *testing.T) {
88 ts := newTestSeq()

Callers

nothing calls this directly

Calls 6

newTestSeqFunction · 0.85
AddMethod · 0.80
DoneMethod · 0.80
MallocMethod · 0.65
StopMethod · 0.65
SwapMethod · 0.45

Tested by

no test coverage detected