Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions attribute/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,59 @@
b.Run("Emit", benchmarkEmit(kv))
}

func BenchmarkSetEquals(b *testing.B) {
b.Run("Empty", func(b *testing.B) {
benchmarkEquals(b, attribute.EmptySet())

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / compatibility-test (1.24.0, ubuntu-latest, 386)

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / compatibility-test (1.23.0, ubuntu-latest, 386)

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / compatibility-test (1.25.0, ubuntu-22.04-arm, arm64)

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / compatibility-test (1.25.0, ubuntu-latest, 386)

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / compatibility-test (1.24.0, ubuntu-latest, amd64)

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / test-bench

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / test-coverage

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / test-race

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / test-concurrent-safe

undefined: benchmarkEquals

Check failure on line 277 in attribute/benchmark_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: benchmarkEquals (typecheck)
})
b.Run("1 string attribute", func(b *testing.B) {
set := attribute.NewSet(attribute.String("string", "42"))
benchmarkSetEquals(b, &set)
})
b.Run("10 string attributes", func(b *testing.B) {
set := attribute.NewSet(
attribute.String("a", "42"),
attribute.String("b", "42"),
attribute.String("c", "42"),
attribute.String("d", "42"),
attribute.String("e", "42"),
attribute.String("f", "42"),
attribute.String("g", "42"),
attribute.String("h", "42"),
attribute.String("i", "42"),
attribute.String("j", "42"),
)
benchmarkSetEquals(b, &set)
})
b.Run("1 int attribute", func(b *testing.B) {
set := attribute.NewSet(attribute.Int("string", 42))
benchmarkSetEquals(b, &set)
})
b.Run("10 int attributes", func(b *testing.B) {
set := attribute.NewSet(
attribute.Int("a", 42),
attribute.Int("b", 42),
attribute.Int("c", 42),
attribute.Int("d", 42),
attribute.Int("e", 42),
attribute.Int("f", 42),
attribute.Int("g", 42),
attribute.Int("h", 42),
attribute.Int("i", 42),
attribute.Int("j", 42),
)
benchmarkSetEquals(b, &set)
})
}

func benchmarkSetEquals(b *testing.B, set *attribute.Set) {
b.ResetTimer()
for range b.N {
if !set.Equals(set) {
b.Fatal("not equal")
}
}
}

// BenchmarkEquivalentMapAccess measures how expensive it is to use
// Equivalent() as a map key. This is on the hot path for making synchronous
// measurements on the metrics API/SDK. It will likely be on the hot path for
Expand Down
Loading