@@ -44,36 +44,6 @@ func TestFromAttributeIndices(t *testing.T) {
4444 assert .Equal (t , attrs .AsRaw (), m )
4545}
4646
47- func TestAddAttribute (t * testing.T ) {
48- table := NewAttributeTableSlice ()
49- att := table .AppendEmpty ()
50- att .SetKey ("hello" )
51- att .Value ().SetStr ("world" )
52-
53- // Add a brand new attribute
54- loc := NewLocation ()
55- err := AddAttribute (table , loc , "bonjour" , pcommon .NewValueStr ("monde" ))
56- require .NoError (t , err )
57-
58- assert .Equal (t , 2 , table .Len ())
59- assert .Equal (t , []int32 {1 }, loc .AttributeIndices ().AsRaw ())
60-
61- // Add an already existing attribute
62- mapp := NewMapping ()
63- err = AddAttribute (table , mapp , "hello" , pcommon .NewValueStr ("world" ))
64- require .NoError (t , err )
65-
66- assert .Equal (t , 2 , table .Len ())
67- assert .Equal (t , []int32 {0 }, mapp .AttributeIndices ().AsRaw ())
68-
69- // Add a duplicate attribute
70- err = AddAttribute (table , mapp , "hello" , pcommon .NewValueStr ("world" ))
71- require .NoError (t , err )
72-
73- assert .Equal (t , 2 , table .Len ())
74- assert .Equal (t , []int32 {0 }, mapp .AttributeIndices ().AsRaw ())
75- }
76-
7747func TestPutAttribute (t * testing.T ) {
7848 table := NewAttributeTableSlice ()
7949 indices := NewProfile ()
@@ -136,75 +106,6 @@ func BenchmarkFromAttributeIndices(b *testing.B) {
136106 }
137107}
138108
139- func BenchmarkAddAttribute (b * testing.B ) {
140- for _ , bb := range []struct {
141- name string
142- key string
143- value pcommon.Value
144-
145- runBefore func (* testing.B , AttributeTableSlice , attributable )
146- }{
147- {
148- name : "with a new string attribute" ,
149- key : "attribute" ,
150- value : pcommon .NewValueStr ("test" ),
151- },
152- {
153- name : "with an existing attribute" ,
154- key : "attribute" ,
155- value : pcommon .NewValueStr ("test" ),
156-
157- runBefore : func (_ * testing.B , table AttributeTableSlice , _ attributable ) {
158- entry := table .AppendEmpty ()
159- entry .SetKey ("attribute" )
160- entry .Value ().SetStr ("test" )
161- },
162- },
163- {
164- name : "with a duplicate attribute" ,
165- key : "attribute" ,
166- value : pcommon .NewValueStr ("test" ),
167-
168- runBefore : func (_ * testing.B , table AttributeTableSlice , obj attributable ) {
169- require .NoError (b , AddAttribute (table , obj , "attribute" , pcommon .NewValueStr ("test" )))
170- },
171- },
172- {
173- name : "with a hundred attributes to loop through" ,
174- key : "attribute" ,
175- value : pcommon .NewValueStr ("test" ),
176-
177- runBefore : func (_ * testing.B , table AttributeTableSlice , _ attributable ) {
178- for i := range 100 {
179- entry := table .AppendEmpty ()
180- entry .SetKey (fmt .Sprintf ("attr_%d" , i ))
181- entry .Value ().SetStr ("test" )
182- }
183-
184- entry := table .AppendEmpty ()
185- entry .SetKey ("attribute" )
186- entry .Value ().SetStr ("test" )
187- },
188- },
189- } {
190- b .Run (bb .name , func (b * testing.B ) {
191- table := NewAttributeTableSlice ()
192- obj := NewLocation ()
193-
194- if bb .runBefore != nil {
195- bb .runBefore (b , table , obj )
196- }
197-
198- b .ResetTimer ()
199- b .ReportAllocs ()
200-
201- for n := 0 ; n < b .N ; n ++ {
202- _ = AddAttribute (table , obj , bb .key , bb .value )
203- }
204- })
205- }
206- }
207-
208109func BenchmarkPutAttribute (b * testing.B ) {
209110 for _ , bb := range []struct {
210111 name string
0 commit comments