🖼 算计的小爪子
#Bing_Wallpaper
算计的小爪子
卡鲁拉国家公园的两只幼年赤狐, 爱沙尼亚 (© Sven Zacek/Nature Picture Library)
4K | 1080P
Invalid media: image
#Bing_Wallpaper
算计的小爪子
卡鲁拉国家公园的两只幼年赤狐, 爱沙尼亚 (© Sven Zacek/Nature Picture Library)
4K | 1080P
Invalid media: image
@@ -65,12 +65,13 @@ func consumeCallback(ring eventRing) (int, uint64) {
ops int
digest uint64
)
+ f := func(chunk []byte) error {
+ digest += binary.LittleEndian.Uint64(chunk[:8])
+ ops++
+ return nil
+ }
for range totalItems {
- err := readFunc(ring, func(chunk []byte) error {
- digest += binary.LittleEndian.Uint64(chunk[:8])
- ops++
- return nil
- })
+ err := readFunc(ring, f)
if err != nil {
panic(err)
} 99.62% 0.00% purego_callback purego_callback_repro [.] runtime.goexit.abi0
|
---runtime.goexit.abi0
runtime.main
main.main
|
--98.72%--main.consumeCallback2
|
|--79.03%--runtime.newobject 0x000000000049cb68 <+104>: call 0x413f00 <runtime.newobject>
0x000000000049cb6d <+109>: lea 0x14c(%rip),%rcx # 0x49ccc0 <main.consumeCallback.func1> 0x000000000049cbc0 <+192>: call 0x413f00 <runtime.newobject>
0x000000000049cbc5 <+197>: lea 0x94(%rip),%rcx # 0x49cc60 <main.consumeCallback.readFunc.readWithPoll.consumeCallback.readFunc.func2.func3>func readFunc(ring eventRing, f func(chunk []byte) error) error {
return readWithPoll(func() error {
return ring.readRecordFunc(func(chunk []byte) error {
return f(chunk)
})
})
}@@ -24,12 +24,12 @@ func (r *Ring) readRecordFunc(f func(chunk []byte) error) error {
return f(r.data[:chunkBytes])
}
-func readWithPoll(read func() error) error {
+func readWithPoll(ring eventRing, read func() error) error {
return read()
}
func readInto(ring eventRing, rec *[chunkBytes]byte) error {
- return readWithPoll(func() error {
+ return readWithPoll(ring, func() error {
return ring.readRecordFunc(func(chunk []byte) error {
copy(rec[:], chunk)
return nil
@@ -38,10 +38,8 @@ func readInto(ring eventRing, rec *[chunkBytes]byte) error {
}
func readFunc(ring eventRing, f func(chunk []byte) error) error {
- return readWithPoll(func() error {
- return ring.readRecordFunc(func(chunk []byte) error {
- return f(chunk)
- })
+ return readWithPoll(ring, func() error {
+ return ring.readRecordFunc(f)
})
} |--97.11%--main.main
| |
| |--94.43%--main.consumeCallback
| | |
| | |--48.08%--main.(*Ring).readRecordFunc
| | | |
| | | --33.64%--main.consumeCallback.func1