We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 287a237 commit 0069c94Copy full SHA for 0069c94
1 file changed
property_test.go
@@ -125,3 +125,34 @@ func BenchmarkAllocProperty(b *testing.B) {
125
})
126
}
127
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
149
150
151
+ v, ok = err.Property(properties[0])
152
153
154
155
156
+ })
157
158
+}
0 commit comments