MCPcopy
hub / github.com/nats-io/nats.go / BenchmarkRequest

Function BenchmarkRequest

test/bench_test.go:132–151  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

130}
131
132func BenchmarkRequest(b *testing.B) {
133 b.StopTimer()
134 s := RunDefaultServer()
135 defer s.Shutdown()
136 nc := NewDefaultConnection(b)
137 defer nc.Close()
138 ok := []byte("ok")
139 nc.Subscribe("req", func(m *nats.Msg) {
140 nc.Publish(m.Reply, ok)
141 })
142 b.StartTimer()
143 b.ReportAllocs()
144 q := []byte("q")
145 for i := 0; i < b.N; i++ {
146 _, err := nc.Request("req", q, 1*time.Second)
147 if err != nil {
148 b.Fatalf("Err %v\n", err)
149 }
150 }
151}
152
153func BenchmarkOldRequest(b *testing.B) {
154 b.StopTimer()

Callers

nothing calls this directly

Calls 7

FatalfMethod · 0.80
RunDefaultServerFunction · 0.70
NewDefaultConnectionFunction · 0.70
SubscribeMethod · 0.65
PublishMethod · 0.65
CloseMethod · 0.45
RequestMethod · 0.45

Tested by

no test coverage detected