File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,34 @@ const (
3939
4040```
4141
42+ ### Reflected structure TypeOf underlying structure:
43+ ```
44+
45+ func TypeOf(i interface{}) Type {
46+ eface := *(*emptyInterface)(unsafe.Pointer(&i)) // runtime.eface
47+ return toType(eface.type)
48+ }
49+
50+ type Type interface {
51+ Align() int
52+ FieldAlign() int
53+ Method(int) Method
54+ MethodByName(string) (Method, bool)
55+ NumMethod() int
56+ Name() string
57+ PkgPath() string
58+ Size() uintptr
59+ String() string
60+ Kind() Kind //Kind Sign
61+ Implements(u Type) bool
62+ AssignableTo(u Type) bool
63+ ConvertibleTo(u Type) bool
64+ Comparable() bool
65+ //... more fields
66+ }
67+
68+ ```
69+
4270### General principles of reflection performance
4371
4472The general principles of numerical analysis of benchmark results suggest:
Original file line number Diff line number Diff line change @@ -39,6 +39,34 @@ const (
3939
4040```
4141
42+ ### 反射的结构TypeOf底层结构:
43+ ```
44+
45+ func TypeOf(i interface{}) Type {
46+ eface := *(*emptyInterface)(unsafe.Pointer(&i)) // runtime.eface
47+ return toType(eface.type)
48+ }
49+
50+ type Type interface {
51+ Align() int
52+ FieldAlign() int
53+ Method(int) Method
54+ MethodByName(string) (Method, bool)
55+ NumMethod() int
56+ Name() string
57+ PkgPath() string
58+ Size() uintptr
59+ String() string
60+ Kind() Kind //Kind Sign
61+ Implements(u Type) bool
62+ AssignableTo(u Type) bool
63+ ConvertibleTo(u Type) bool
64+ Comparable() bool
65+ //... 更多字段
66+ }
67+
68+ ```
69+
4270### 反射性能的一般原则
4371
4472基准测试结果的数值分析的一般原则建议:
You can’t perform that action at this time.
0 commit comments