File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -125,3 +125,34 @@ func BenchmarkAllocProperty(b *testing.B) {
125125 })
126126 }
127127}
128+
129+ var sum int
130+
131+ func BenchmarkGetProperty (b * testing.B ) {
132+ const N = 9
133+ var properties = []Property {}
134+ for j := 0 ; j < N ; j ++ {
135+ n := fmt .Sprintf ("props%d" , j )
136+ properties = append (properties , RegisterProperty (n ))
137+ b .Run (n , func (b * testing.B ) {
138+ err := testTypeSilent .New ("test" )
139+ for i := 0 ; i < j ; i ++ {
140+ err = err .WithProperty (properties [i ], 42 )
141+ }
142+ for k := 0 ; k < b .N ; k ++ {
143+ v , ok := err .Property (testProperty0 )
144+ if ok {
145+ sum += v .(int )
146+ }
147+ v , ok = err .Property (properties [j ])
148+ if ok {
149+ sum += v .(int )
150+ }
151+ v , ok = err .Property (properties [0 ])
152+ if ok {
153+ sum += v .(int )
154+ }
155+ }
156+ })
157+ }
158+ }
You can’t perform that action at this time.
0 commit comments