MCPcopy
hub / github.com/CodisLabs/codis / benchmarkRequestChanN

Function benchmarkRequestChanN

pkg/proxy/request_test.go:110–126  ·  view source on GitHub ↗
(b *testing.B, n int)

Source from the content-addressed store, hash-verified

108}
109
110func benchmarkRequestChanN(b *testing.B, n int) {
111 var request = &Request{
112 Multi: make([]*redis.Resp, 1024*1024),
113 }
114 var ch = NewRequestChanBuffer(n)
115 go func() {
116 defer ch.Close()
117 for i := 0; i < b.N; i++ {
118 ch.PushBack(request)
119 if i%1024 == 0 {
120 runtime.Gosched()
121 }
122 }
123 }()
124
125 ch.PopFrontAllVoid(func(r *Request) {})
126}
127
128func BenchmarkRequestChan128(b *testing.B) { benchmarkRequestChanN(b, 128) }
129func BenchmarkRequestChan256(b *testing.B) { benchmarkRequestChanN(b, 256) }

Callers 5

BenchmarkRequestChan128Function · 0.85
BenchmarkRequestChan256Function · 0.85
BenchmarkRequestChan512Function · 0.85
BenchmarkRequestChan1024Function · 0.85
BenchmarkRequestChan2048Function · 0.85

Calls 4

NewRequestChanBufferFunction · 0.85
PopFrontAllVoidMethod · 0.80
CloseMethod · 0.65
PushBackMethod · 0.45

Tested by

no test coverage detected