Repository: envoyproxy/gateway

Issue:
Run go test -bench on Translate
*Description*:
>Describe the issue.

Add Benchmark tests  https://pkg.go.dev/testing#hdr-Benchmarks
for Gateway API Translate and Xds Translate functions

[optional *Relevant Links*:]
>Any extra documentation required to understand the issue.


Hints from issue comments:
@arkodg: most the work is already done thanks to @mathetake , the test lives in https://github.com/envoyproxy/gateway/blob/main/test/gobench/translate_test.go

can we invoked via cmd like `go test -run='^$' -bench=. -benchmem -benchtime=1x -count=3 `

and the output can be compared with and w/o the change using benchstat  https://pkg.go.dev/golang.org/x/perf/cmd/benchstat

Remaining work items are
* adding a make target
* running this in the CI https://github.com/envoyproxy/gateway/blob/main/.github/workflows/build_and_test.yaml

Solution patch:
diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml
index 4728272ba..516626c98 100644
--- a/.github/workflows/build_and_test.yaml
+++ b/.github/workflows/build_and_test.yaml
@@ -86,6 +86,17 @@ jobs:
         verbose: true
         use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}
 
+  go-benchmark-test:
+    runs-on: ubuntu-latest
+    needs:
+    - changes
+    if: ${{ github.event_name != 'pull_request' || needs.changes.outputs.run_test_workflow == 'true' }}
+    steps:
+    - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8  # v5.0.0
+    - uses: ./tools/github-actions/setup-deps
+    - name: Run Go Benchmark Tests
+      run: make go-benchmark
+
   build:
     runs-on: ubuntu-latest
     needs: [changes, lint, gen-check, license-check, coverage-test]
diff --git a/tools/make/golang.mk b/tools/make/golang.mk
index b126e1b25..0060a3e25 100644
--- a/tools/make/golang.mk
+++ b/tools/make/golang.mk
@@ -81,6 +81,11 @@ go.test.cel: manifests # Run the CEL validation tests
          go test ./test/cel-validation --tags celvalidation -race || exit 1; \
     done
 
+.PHONY: go.test.benchmark
+go.test.benchmark: ## Run benchmark tests for translation performance
+	@$(LOG_TARGET)
+	go test -timeout=10m -run='^$$' -bench=. -benchmem -benchtime=1x -count=3 ./test/gobench
+
 .PHONY: go.clean
 go.clean: ## Clean the building output files
 	@$(LOG_TARGET)
@@ -139,3 +144,7 @@ clean: go.clean
 .PHONY: testdata
 testdata: ## Override the testdata with new configurations.
 testdata: go.testdata.complete
+
+.PHONY: go-benchmark
+go-benchmark: ## Run benchmark tests for translation performance.
+go-benchmark: go.test.benchmark



Test patch:
diff --git a/test/gobench/translate_test.go b/test/gobench/translate_test.go
index cc1abaac1..ee2410d68 100644
--- a/test/gobench/translate_test.go
+++ b/test/gobench/translate_test.go
@@ -313,17 +313,17 @@ func BenchmarkGatewayAPItoXDS(b *testing.B) {
 		yaml string
 	}
 	medium := baseYAML + backendYAML + tlsSecretYAML + clientTrafficPolicyYAML +
-		genHTTPRoutes(100) +
-		genGRPCRoutes(50) +
-		genUDPRoutes(20) +
-		genSecurityPolicies(100) +
-		genBackendTrafficPolicies(100)
+		genHTTPRoutes(50) +
+		genGRPCRoutes(25) +
+		genUDPRoutes(10) +
+		genSecurityPolicies(50) +
+		genBackendTrafficPolicies(50)
 	large := baseYAML + backendYAML + tlsSecretYAML + clientTrafficPolicyYAML +
-		genHTTPRoutes(1000) +
-		genGRPCRoutes(500) +
+		genHTTPRoutes(500) +
+		genGRPCRoutes(250) +
 		genUDPRoutes(100) +
-		genSecurityPolicies(1000) +
-		genBackendTrafficPolicies(1000)
+		genSecurityPolicies(500) +
+		genBackendTrafficPolicies(500)
 
 	cases := []benchCase{
 		{