2 ms·
Synchronized, NSLock, pthread, OSSpinLock comparative performance
- DenisM 14y agoJust ran this on my macbook pro core i7: NSLock: 3.364240 sec NSLock+IMP Cache: 2.772781 sec pthread_mutex: 1.733382 sec OSSpinlock: 0.323426 sec @synchronized: 4.250744 sec isMainThread: 0.373637 sec myDummy++: 0.063998 sec The last two are [NSThread isMainThread], and a simple increment of a static variable. And same test on the iPhone 4s: NSLock: 21.619565 sec NSLock+IMP Cache: 18.740027 sec pthread_mutex: 11.585992 sec OSSpinlock: 3.576578 sec @synchronized: 28.453087 sec isMainThread: 2.662025 sec myDummy++: 0.634946 sec