Skip to content

Commit 8fb51e4

Browse files
committed
property allocation test
1 parent 79bc001 commit 8fb51e4

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

property_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package errorx
22

33
import (
4+
"fmt"
45
"testing"
56

67
"github.com/stretchr/testify/require"
@@ -107,3 +108,20 @@ func TestProperty(t *testing.T) {
107108
require.Nil(t, property1)
108109
})
109110
}
111+
112+
func BenchmarkAllocProperty(b *testing.B) {
113+
const N = 9
114+
var properties = []Property{}
115+
for j := 0; j < N; j++ {
116+
n := fmt.Sprintf("props%d", j)
117+
properties = append(properties, RegisterProperty(n))
118+
b.Run(n, func(b *testing.B) {
119+
for k := 0; k < b.N; k++ {
120+
err := testTypeSilent.New("test")
121+
for i := 0; i < j; i++ {
122+
err = err.WithProperty(properties[i], 42)
123+
}
124+
}
125+
})
126+
}
127+
}

0 commit comments

Comments
 (0)