You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
Update the benchmarks to only record/display select benchmarks. (#4560)
* Add a benchmark target to makefile * update CI to reflect how the benchmarks will be used * Add auto-push to benchmarks branch. --------- Co-authored-by: Robert Pająk <pellared@hotmail.com>
This commit is contained in:
@@ -1,21 +1,24 @@
|
|||||||
name: Benchmark
|
name: Benchmark
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- v1.*
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DEFAULT_GO_VERSION: "~1.21.3"
|
DEFAULT_GO_VERSION: "~1.21.3"
|
||||||
jobs:
|
jobs:
|
||||||
benchmark:
|
benchmark:
|
||||||
name: Benchmarks
|
name: Benchmarks
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.DEFAULT_GO_VERSION }}
|
go-version: ${{ env.DEFAULT_GO_VERSION }}
|
||||||
- name: Run benchmarks
|
- name: Run benchmarks
|
||||||
run: make test-bench | tee output.txt
|
run: make benchmark | tee output.txt
|
||||||
- name: Download previous benchmark data
|
- name: Download previous benchmark data
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
@@ -28,6 +31,8 @@ jobs:
|
|||||||
tool: 'go'
|
tool: 'go'
|
||||||
output-file-path: output.txt
|
output-file-path: output.txt
|
||||||
external-data-json-path: ./benchmarks/data.json
|
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
|
fail-on-alert: false
|
||||||
alert-threshold: "400%"
|
alert-threshold: "400%"
|
||||||
|
|||||||
@@ -45,6 +45,22 @@ jobs:
|
|||||||
run: make build
|
run: make build
|
||||||
- name: Check clean repository
|
- name: Check clean repository
|
||||||
run: make check-clean-work-tree
|
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:
|
test-race:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -192,6 +192,18 @@ test-coverage: | $(GOCOVMERGE)
|
|||||||
done; \
|
done; \
|
||||||
$(GOCOVMERGE) $$(find . -name coverage.out) > coverage.txt
|
$(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
|
.PHONY: golangci-lint golangci-lint-fix
|
||||||
golangci-lint-fix: ARGS=--fix
|
golangci-lint-fix: ARGS=--fix
|
||||||
golangci-lint-fix: golangci-lint
|
golangci-lint-fix: golangci-lint
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ func BenchmarkPrepend(b *testing.B) {
|
|||||||
|
|
||||||
func BenchmarkAppend(b *testing.B) {
|
func BenchmarkAppend(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
agg := newExpoHistogramDataPoint[float64](1024, 200, false, false)
|
agg := newExpoHistogramDataPoint[float64](1024, 20, false, false)
|
||||||
n := smallestNonZeroNormalFloat64
|
n := smallestNonZeroNormalFloat64
|
||||||
for j := 0; j < 1024; j++ {
|
for j := 0; j < 1024; j++ {
|
||||||
agg.record(n)
|
agg.record(n)
|
||||||
|
|||||||
Reference in New Issue
Block a user