(b *testing.B)
| 973 | } |
| 974 | |
| 975 | func 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 | } |
nothing calls this directly
no test coverage detected