@@ -19,10 +19,15 @@ import (
1919 "testing"
2020
2121 "github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/data"
22+ "github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/sdkinstrument"
2223 "github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/view"
2324 "go.opentelemetry.io/otel/attribute"
2425)
2526
27+ var unsafePerf = WithPerformance (sdkinstrument.Performance {
28+ IgnoreCollisions : true ,
29+ })
30+
2631// Tested prior to 0.11.0 release
2732// goos: darwin
2833// goarch: arm64
@@ -64,6 +69,19 @@ func BenchmarkCounterAddOneAttr(b *testing.B) {
6469 }
6570}
6671
72+ func BenchmarkCounterAddOneAttrUnsafe (b * testing.B ) {
73+ ctx := context .Background ()
74+ rdr := NewManualReader ("bench" )
75+ provider := NewMeterProvider (WithReader (rdr ), unsafePerf )
76+ b .ReportAllocs ()
77+
78+ cntr , _ := provider .Meter ("test" ).Int64Counter ("hello" )
79+
80+ for i := 0 ; i < b .N ; i ++ {
81+ cntr .Add (ctx , 1 , attribute .String ("K" , "V" ))
82+ }
83+ }
84+
6785func BenchmarkCounterAddOneInvalidAttr (b * testing.B ) {
6886 ctx := context .Background ()
6987 rdr := NewManualReader ("bench" )
@@ -90,6 +108,19 @@ func BenchmarkCounterAddManyAttrs(b *testing.B) {
90108 }
91109}
92110
111+ func BenchmarkCounterAddManyAttrsUnsafe (b * testing.B ) {
112+ ctx := context .Background ()
113+ rdr := NewManualReader ("bench" )
114+ provider := NewMeterProvider (WithReader (rdr ), unsafePerf )
115+ b .ReportAllocs ()
116+
117+ cntr , _ := provider .Meter ("test" ).Int64Counter ("hello" )
118+
119+ for i := 0 ; i < b .N ; i ++ {
120+ cntr .Add (ctx , 1 , attribute .Int ("K" , i ))
121+ }
122+ }
123+
93124func BenchmarkCounterAddManyInvalidAttrs (b * testing.B ) {
94125 ctx := context .Background ()
95126 rdr := NewManualReader ("bench" )
@@ -103,6 +134,19 @@ func BenchmarkCounterAddManyInvalidAttrs(b *testing.B) {
103134 }
104135}
105136
137+ func BenchmarkCounterAddManyInvalidAttrsUnsafe (b * testing.B ) {
138+ ctx := context .Background ()
139+ rdr := NewManualReader ("bench" )
140+ provider := NewMeterProvider (WithReader (rdr ), unsafePerf )
141+ b .ReportAllocs ()
142+
143+ cntr , _ := provider .Meter ("test" ).Int64Counter ("hello" )
144+
145+ for i := 0 ; i < b .N ; i ++ {
146+ cntr .Add (ctx , 1 , attribute .Int ("" , i ), attribute .Int ("K" , i ))
147+ }
148+ }
149+
106150func BenchmarkCounterAddManyFilteredAttrs (b * testing.B ) {
107151 ctx := context .Background ()
108152 rdr := NewManualReader ("bench" )
0 commit comments