Re: Does CFSocket use efficient polling?
Re: Does CFSocket use efficient polling?
- Subject: Re: Does CFSocket use efficient polling?
- From: Ladd Van Tol <email@hidden>
- Date: Fri, 13 Feb 2009 18:44:20 -0800
On Feb 13, 2009, at 4:28 PM, Jens Alfke wrote:
On Feb 13, 2009, at 3:59 PM, Ladd Van Tol wrote:
1) Using NSURLConnection to download data, appending to
NSMutableData in the delegate's connection:didReceiveData:. Caching
is turned off.
2) Using libcurl's easy interface in a thread spawned for each
connection, notifying back to the main thread on completion (with
performSelectorOnMainThread). Curl does not appear to do any
content caching.
Did you sample test #1 to see where the time is spent?
Sampling is not particularly illuminating right on the face of it --
some time is spent memcpying, but it's not dominating the sample --
lots of time spent on context switching and the like.
Repeated appends to an NSMutableData will do a lot of memcpy's as it
grows its buffer, with performance roughly O(n^2). It sounds like
test #2 isn't storing the data at all, so this isn't a fair
comparison.
Yes, I'm storing the data in test #2, as you can see in the source.
Also, if you look at the code, you'll see that my implementation for
NSURLConnection is actually MORE optimal, as it pre-sizes the capacity
buffer according the the content-length, where possible.
I could also do this for curl, but it's harder, because it requires
some manual header parsing (again, a convenience/performance tradeoff).
I've also tried simply throwing the data away, and the performance is
similar.
Also, the data rates you're getting (with your local server) exceed
even gigabit Ethernet capacity. In the real world, very few people
are going to complain when NSURLConnection limits them to 'only'
2000mbps :)
On the iPhone, it gets pretty interesting, and I have a real-world app
that becomes quite sluggish due to background networking that uses
NSURLConnection.
Having more cycles never hurts.
- Ladd
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden