Skip to content

Commit 0069c94

Browse files
committed
property get test
1 parent 287a237 commit 0069c94

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

property_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)