ParseSourceCodeStudy icon indicating copy to clipboard operation
ParseSourceCodeStudy copied to clipboard

为什么dispatch_async放在for循环效率会变那么高

Open PhilCai1993 opened this issue 9 years ago • 3 comments

PhilCai1993 avatar Apr 25 '16 04:04 PhilCai1993

因为for循环中所需要执行的任务都dispatch到后台执行了,所以每次循环都是立刻返回。 这里还可以用dispatch_apply来代替,更加明了一些。@ChenYilong

jasonhotsauce avatar Jun 21 '16 17:06 jasonhotsauce

@jasonhotsauce 做 dispatch_async这个操作不会很耗时咯?

PhilCai1993 avatar Jun 22 '16 02:06 PhilCai1993

做 dispatch_async这个操作不会很耗时咯?

这个要相对的来看,一般来说是不太影响performance的,但是如果滥用的话,也会有问题。

jasonhotsauce avatar Jun 22 '16 14:06 jasonhotsauce