MCPcopy
hub / github.com/jmoiron/sqlx / BenchmarkTraversalsByName

Function BenchmarkTraversalsByName

reflectx/reflect_test.go:945–973  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

943}
944
945func BenchmarkTraversalsByName(b *testing.B) {
946 type A struct {
947 Value int
948 }
949
950 type B struct {
951 A A
952 }
953
954 type C struct {
955 B B
956 }
957
958 type D struct {
959 C C
960 }
961
962 m := NewMapper("")
963 t := reflect.TypeOf(D{})
964 names := []string{"C", "B", "A", "Value"}
965
966 b.ResetTimer()
967
968 for i := 0; i < b.N; i++ {
969 if l := len(m.TraversalsByName(t, names)); l != len(names) {
970 b.Errorf("expected %d values, got %d", len(names), l)
971 }
972 }
973}
974
975func BenchmarkTraversalsByNameFunc(b *testing.B) {
976 type A struct {

Callers

nothing calls this directly

Calls 3

TraversalsByNameMethod · 0.95
NewMapperFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected