Skip to content

Commit

Permalink
request_test: add some benchmark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Jul 24, 2024
1 parent 73f38ea commit 83016ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
run: go build -v ./...

- name: Test
run: go test -short -v ./...
run: go test -bench=. -short -v ./...
19 changes: 19 additions & 0 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ func TestPrepareRequestsError(t *testing.T) {
assert.Error(t, err)
}

func BenchmarkPrepareRequests(b *testing.B) {
params := genParams("param", 10000)

for i := 0; i < b.N; i++ {
prepareRequests("command", params)
}
}

func TestValidateResponse(t *testing.T) {
// Dummy client to allow this test to run without Hyprland
c := DummyClient{}
Expand Down Expand Up @@ -162,6 +170,17 @@ func TestValidateResponse(t *testing.T) {
}
}

func BenchmarkValidateResponse(b *testing.B) {
// Dummy client to allow this test to run without Hyprland
c := DummyClient{}
params := genParams("param", 10000)
response := strings.Repeat("ok"+strings.Repeat(" ", 1000), 10000)

for i := 0; i < b.N; i++ {
c.validateResponse(params, RawResponse(response))
}
}

func TestRawRequest(t *testing.T) {
testCommandRR(t, func() (RawResponse, error) {
return c.RawRequest([]byte("splash"))
Expand Down

0 comments on commit 83016ef

Please sign in to comment.