In Cocoa, is NSThread faster than pthread? is are any performance gain? is it negligible to ignore?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I have no data to back this up, but I’m going to go out on a limb and say “they’re equivalent”.
NSThreadis almost certainly wrapper around pthread (is there really any other way to create a system thread?), so any overhead of usingNSThreadversus pthread would be that associated with creating a new object and then destroying it. Once the thread itself starts, it should be pretty much identical in terms of performance.I think the real question here is: “Why do you need to know?” Have you come up against some situation where spawning
NSThreads seems to be detrimental to your performance? (I could see this being an issue if you’re spawning hundreds of threads, but in that case, the hundreds of threads are most likely your problem, and not theNSThreadobjects)Unless you have proof that the creation of an
NSThreadobject is a bottleneck in your application, I would definitely go with the “negligible to ignore” option.