Skip to content

Commit

Permalink
add benchmark for hotspots
Browse files Browse the repository at this point in the history
  • Loading branch information
myzhan committed Nov 30, 2018
1 parent b839e5c commit 1267d3c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func TestLogRequest(t *testing.T) {
}
}

func BenchmarkLogRequest(b *testing.B) {
newStats := newRequestStats()
for i := 0; i < b.N; i++ {
newStats.logRequest("http", "success", 2, 30)
}
}

func TestRoundedResponseTime(t *testing.T) {
newStats := newRequestStats()
newStats.logRequest("http", "success", 147, 1)
Expand Down Expand Up @@ -106,6 +113,15 @@ func TestLogError(t *testing.T) {
}
}

func BenchmarkLogError(b *testing.B) {
newStats := newRequestStats()
for i := 0; i < b.N; i++ {
// LogError use md5 to calculate hash keys, it may slow down the only goroutine,
// which consumes both requestSuccessChannel and requestFailureChannel.
newStats.logError("http", "failure", "500 error")
}
}

func TestClearAll(t *testing.T) {
newStats := newRequestStats()
newStats.logRequest("http", "success", 1, 20)
Expand Down

0 comments on commit 1267d3c

Please sign in to comment.