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

Function TestBenchSetup

bench/benchlib_test.go:153–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestBenchSetup(t *testing.T) {
154 bench := NewBenchmark("test", 1, 1)
155 bench.AddSubSample(millionMessagesSecondSample(1))
156 bench.AddPubSample(millionMessagesSecondSample(1))
157 bench.Close()
158 if len(bench.RunID) == 0 {
159 t.Fatal("Bench doesn't have a RunID")
160 }
161 if len(bench.Pubs.Samples) != 1 {
162 t.Fatal("Expected one publisher")
163 }
164 if len(bench.Subs.Samples) != 1 {
165 t.Fatal("Expected one subscriber")
166 }
167 if bench.MsgCnt != 2*Million {
168 t.Fatal("Expected 2 million msgs")
169 }
170 if bench.IOBytes != 2*Million*MsgSize {
171 t.Fatalf("Expected %d million bytes", 2*MsgSize)
172 }
173 if bench.Duration() != time.Second {
174 t.Fatal("Expected duration to be 1 second")
175 }
176}
177
178func makeBench(subs, pubs int) *Benchmark {
179 bench := NewBenchmark("test", subs, pubs)

Callers

nothing calls this directly

Calls 7

AddSubSampleMethod · 0.95
AddPubSampleMethod · 0.95
CloseMethod · 0.95
NewBenchmarkFunction · 0.85
FatalfMethod · 0.80
DurationMethod · 0.80

Tested by

no test coverage detected