README ¶ 测试switch和回调函数效率差异。 实验结果: dada-imac:labs18 dada$ go test -bench=".*" testing: warning: no tests to run PASS Benchmark_UseSwitch 200000000 9.58 ns/op Benchmark_UseCallback 200000000 8.05 ns/op ok github.com/idada/go-labs/labs18 5.323s Expand ▾ Collapse ▴ Documentation ¶ Index ¶ type MyObject func New() *MyObject func NewCallback() *MyObject func (obj *MyObject) UseCallback() int func (obj *MyObject) UseSwitch() int Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type MyObject ¶ type MyObject struct { // contains filtered or unexported fields } func New ¶ func New() *MyObject func NewCallback ¶ func NewCallback() *MyObject func (*MyObject) UseCallback ¶ func (obj *MyObject) UseCallback() int func (*MyObject) UseSwitch ¶ func (obj *MyObject) UseSwitch() int Source Files ¶ View all Source files labs18.go Click to show internal directories. Click to hide internal directories.