Added profile target for running profiled benchmarks
This commit is contained in:
parent
d25d41ad2a
commit
2691a13825
|
@ -1,6 +1,7 @@
|
|||
*~*
|
||||
dist
|
||||
*.bak
|
||||
*.prof
|
||||
coverage.txt
|
||||
cmd/msgbus/msgbus
|
||||
cmd/msgbusd/msgbusd
|
||||
|
|
2
Makefile
2
Makefile
|
@ -37,6 +37,8 @@ image:
|
|||
@docker build --build-arg TAG=$(TAG) --build-arg BUILD=$(BUILD) -t $(REPO):$(TAG) .
|
||||
@echo "Image created: $(REPO):$(TAG)"
|
||||
|
||||
profile:
|
||||
@go test -cpuprofile cpu.prof -memprofile mem.prof -v -bench=. $(TEST_ARGS)
|
||||
bench:
|
||||
@go test -v -bench=. $(TEST_ARGS)
|
||||
|
||||
|
|
|
@ -78,19 +78,6 @@ func TestServeHTTPPOST(t *testing.T) {
|
|||
assert.Regexp(`message successfully published to hello with sequence \d+`, w.Body.String())
|
||||
}
|
||||
|
||||
func TestServeHTTPPUT(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
mb := New(nil)
|
||||
w := httptest.NewRecorder()
|
||||
b := bytes.NewBufferString("hello world")
|
||||
r, _ := http.NewRequest("PUT", "/hello", b)
|
||||
|
||||
mb.ServeHTTP(w, r)
|
||||
assert.Equal(w.Code, http.StatusOK)
|
||||
assert.Regexp(`message successfully published to hello with sequence \d+`, w.Body.String())
|
||||
}
|
||||
|
||||
func TestServeHTTPMaxPayloadSize(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
@ -130,6 +117,19 @@ func TestServeHTTPSimple(t *testing.T) {
|
|||
assert.Equal(msg.Payload, []byte("hello world"))
|
||||
}
|
||||
|
||||
func BenchmarkServeHTTPPOST(b *testing.B) {
|
||||
mb := New(nil)
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
w := httptest.NewRecorder()
|
||||
b := bytes.NewBufferString("hello world")
|
||||
r, _ := http.NewRequest("POST", "/hello", b)
|
||||
|
||||
mb.ServeHTTP(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServeHTTPSubscriber(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
|
Loading…
Reference in New Issue