News for hackers. Stuff that matters.
Re:Date parsing performance on iOS (NSDateformatter vs sqlite) by dante_dev on Saturday September 07, 2013 @10:07AM (#6345107)
mmm.....can I see the code about NSDateFormatter? because I feel like you're using it wrong. You need to cache somewhere the NSDateFormatter allocation (it is really expensive), reusing the same instance to convert the string to NSDate*.
Re:Date parsing performance on iOS (NSDateformatter vs sqlite) by MishraAnurag on Saturday September 07, 2013 @10:16AM (#6345133)
A link to the source code is present in the article. You can find it here - https://gist.github.com/AnuragMishra/6474321

The NSDateFormatter is already being cached. That was my first suspicion on finding this issue too. We are using one formatter per thread in the production code, but that doesn't apply for the code I've posted since everything is done on the main thread using a single formatter instance.

Re:Date parsing performance on iOS (NSDateformatter vs sqlite) by asveikau on Saturday September 07, 2013 @12:37PM (#6345540)
sqlite happens after the objc version. Are the results any different when the sqlite code comes first? Actually the fairest comparison would be to store the dataset in a file, and have a process for timing NSDateFormatter, and a different one for testing sqlite. This would eliminate any advantage that a warm cache might give you.
Re:Date parsing performance on iOS (NSDateformatter vs sqlite) by dpratt on Saturday September 07, 2013 @04:20PM (#6346452)
Sadly, NSDateFormatter (and NSFormatter in general) are explicitly not thread safe. You'll either have to just allocate and release on demand or implement some sort of thread-local mechanism. Unfortunately, one of the drawbacks do the (generally excellent) concurrency APIs in macos/iOS is that thread locals are actually sort of a pain to implement. I've been writing cocoa apps for a few years now, and I find the platform to be generally quite good, but I do miss things like Joda time.