Skip to content

Commit

Permalink
add benchmark pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jianzhangbjz committed Feb 8, 2025
1 parent 38be50e commit 08a24d1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Benchmark Test

on:
pull_request:
branches:
- main

jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install dependencies
run: |
go mod download
go mod tidy
# - name: Debug via SSH
# uses: mxschmitt/action-tmate@v3

- name: Run benchmark test
# working-directory: test/e2e
run: |
mkdir -p /tmp/artifacts/
ARTIFACT_PATH=/tmp/artifacts make test-benchmark
- name: Compare with baseline
run: |
go install golang.org/x/perf/cmd/benchstat@latest
benchstat benchmarks/baseline.txt /tmp/artifacts/new.txt | tee /tmp/artifacts/output
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-artifacts
path: /tmp/artifacts/

11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ test: manifests generate fmt lint test-unit test-e2e #HELP Run all tests.
e2e: #EXHELP Run the e2e tests.
go test -count=1 -v ./test/e2e/...

.PHONY: benchmark
benchmark: #EXHELP Run the benchmark tests.
export CATALOG_IMG=registry.redhat.io/redhat/redhat-operator-index:v4.18
go test -v -run=^$$ -bench=. -benchmem -count=10 -v ./test/e2e/... | tee /tmp/artifacts/new.txt

E2E_REGISTRY_NAME := docker-registry
E2E_REGISTRY_NAMESPACE := operator-controller-e2e

Expand Down Expand Up @@ -209,6 +214,12 @@ test-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/e2e
test-e2e: GO_BUILD_FLAGS := -cover
test-e2e: run image-registry e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster

.PHONY: test-benchmark
test-benchmark: KIND_CLUSTER_NAME := operator-controller-benchmark
test-benchmark: KUSTOMIZE_BUILD_DIR := config/overlays/e2e
test-benchmark: GO_BUILD_FLAGS := -cover
test-benchmark: run image-registry benchmark kind-clean #HELP Run benchmark test suite on local kind cluster

.PHONY: extension-developer-e2e
extension-developer-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster
Expand Down
16 changes: 16 additions & 0 deletions benchmarks/baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
goos: darwin
goarch: arm64
pkg: github.com/operator-framework/operator-controller/test/e2e
cpu: Apple M1 Pro
BenchmarkCreateClusterCatalog-10 1 1352852042 ns/op 404520 B/op 3914 allocs/op
BenchmarkCreateClusterCatalog-10 13 86982353 ns/op 36907 B/op 394 allocs/op
BenchmarkCreateClusterCatalog-10 12 84962496 ns/op 34555 B/op 393 allocs/op
BenchmarkCreateClusterCatalog-10 18 70375363 ns/op 34880 B/op 388 allocs/op
BenchmarkCreateClusterCatalog-10 15 71715708 ns/op 37654 B/op 399 allocs/op
BenchmarkCreateClusterCatalog-10 13 85251170 ns/op 36572 B/op 396 allocs/op
BenchmarkCreateClusterCatalog-10 13 83413260 ns/op 38435 B/op 393 allocs/op
BenchmarkCreateClusterCatalog-10 13 93851487 ns/op 37249 B/op 395 allocs/op
BenchmarkCreateClusterCatalog-10 13 78722212 ns/op 36593 B/op 393 allocs/op
BenchmarkCreateClusterCatalog-10 13 86393522 ns/op 37404 B/op 395 allocs/op
PASS
ok github.com/operator-framework/operator-controller/test/e2e 32.699s

0 comments on commit 08a24d1

Please sign in to comment.