diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8b5e9183f..ba3fffd9d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,21 +1,24 @@ name: Benchmark on: push: - branches: - - main + tags: + - v1.* + workflow_dispatch: + env: DEFAULT_GO_VERSION: "~1.21.3" jobs: benchmark: name: Benchmarks runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: ${{ env.DEFAULT_GO_VERSION }} - name: Run benchmarks - run: make test-bench | tee output.txt + run: make benchmark | tee output.txt - name: Download previous benchmark data uses: actions/cache@v3 with: @@ -28,6 +31,8 @@ jobs: tool: 'go' output-file-path: output.txt external-data-json-path: ./benchmarks/data.json - auto-push: false + github-token: ${{ secrets.GITHUB_TOKEN }} + gh-pages-branch: benchmarks + auto-push: true fail-on-alert: false alert-threshold: "400%" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfe8eaf51..76c650b7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,22 @@ jobs: run: make build - name: Check clean repository run: make check-clean-work-tree + test-bench: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + - name: Setup Environment + run: | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + cache-dependency-path: "**/go.sum" + - name: Run benchmarks to check functionality + run: make test-bench test-race: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index be8a10038..0bc547693 100644 --- a/Makefile +++ b/Makefile @@ -192,6 +192,18 @@ test-coverage: | $(GOCOVMERGE) done; \ $(GOCOVMERGE) $$(find . -name coverage.out) > coverage.txt +# Adding a directory will include all benchmarks in that direcotry if a filter is not specified. +BENCHMARK_TARGETS := sdk/trace +.PHONY: benchmark +benchmark: $(BENCHMARK_TARGETS:%=benchmark/%) +BENCHMARK_FILTER = . +# You can override the filter for a particular directory by adding a rule here. +benchmark/sdk/trace: BENCHMARK_FILTER = SpanWithAttributes_8/AlwaysSample +benchmark/%: + @echo "$(GO) test -timeout $(TIMEOUT)s -run=xxxxxMatchNothingxxxxx -bench=$(BENCHMARK_FILTER) $*..." \ + && cd $* \ + $(foreach filter, $(BENCHMARK_FILTER), && $(GO) test -timeout $(TIMEOUT)s -run=xxxxxMatchNothingxxxxx -bench=$(filter)) + .PHONY: golangci-lint golangci-lint-fix golangci-lint-fix: ARGS=--fix golangci-lint-fix: golangci-lint diff --git a/sdk/metric/internal/aggregate/exponential_histogram_test.go b/sdk/metric/internal/aggregate/exponential_histogram_test.go index 7dbb71b15..26b89f0ba 100644 --- a/sdk/metric/internal/aggregate/exponential_histogram_test.go +++ b/sdk/metric/internal/aggregate/exponential_histogram_test.go @@ -676,7 +676,7 @@ func BenchmarkPrepend(b *testing.B) { func BenchmarkAppend(b *testing.B) { for i := 0; i < b.N; i++ { - agg := newExpoHistogramDataPoint[float64](1024, 200, false, false) + agg := newExpoHistogramDataPoint[float64](1024, 20, false, false) n := smallestNonZeroNormalFloat64 for j := 0; j < 1024; j++ { agg.record(n)