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

Function BenchmarkTraversalsByNameFunc

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

Source from the content-addressed store, hash-verified

973}
974
975func BenchmarkTraversalsByNameFunc(b *testing.B) {
976 type A struct {
977 Z int
978 }
979
980 type B struct {
981 A A
982 }
983
984 type C struct {
985 B B
986 }
987
988 type D struct {
989 C C
990 }
991
992 m := NewMapper("")
993 t := reflect.TypeOf(D{})
994 names := []string{"C", "B", "A", "Z", "Y"}
995
996 b.ResetTimer()
997
998 for i := 0; i < b.N; i++ {
999 var l int
1000
1001 if err := m.TraversalsByNameFunc(t, names, func(_ int, _ []int) error {
1002 l++
1003 return nil
1004 }); err != nil {
1005 b.Errorf("unexpected error %s", err)
1006 }
1007
1008 if l != len(names) {
1009 b.Errorf("expected %d values, got %d", len(names), l)
1010 }
1011 }
1012}

Callers

nothing calls this directly

Calls 3

TraversalsByNameFuncMethod · 0.95
NewMapperFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected