Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
- Subject: Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
- From: Jens Alfke <email@hidden>
- Date: Fri, 1 Aug 2008 18:04:34 -0700
On 1 Aug '08, at 3:33 PM, JongAm Park wrote:
I have some codes which were written in Carbon and we want to make
its performance faster.
I found out that most of the time is spent by a series of
FSWriteFork() function. So, I would like to use any method which is
faster than that.
fwrite is one option but I also looked up a Cocoa method, writeData
message of the NSFileHandle.
All of those end up going through the same filesystem calls ('write',
primarily) in the kernel, so one's not going to be faster than
another. I would expect fwrite to be a tiny bit slower because of the
extra buffering that stdio does, and NSFileHandle will also be a
little slower because of the overhead of calling Objective-C methods.
But generally that wouldn't be noticeable.
What really makes a difference is how much data you write on each call
— the more the better. It may also help to use uncached writes, if the
file's not going to be read again soon.
The fs_usage tool can help you see what filesystem calls you're making
and how much data is being sent in every call.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden