{"id":7810,"date":"2013-09-10T12:20:22","date_gmt":"2013-09-10T16:20:22","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=7810"},"modified":"2019-08-05T16:49:14","modified_gmt":"2019-08-05T20:49:14","slug":"date-parsing-performance-nsdateformatter-vs-sqlite","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/09\/10\/date-parsing-performance-nsdateformatter-vs-sqlite\/","title":{"rendered":"Date Parsing Performance: NSDateFormatter vs. SQLite"},"content":{"rendered":"<p><a href=\"http:\/\/thought-palace.tumblr.com\/post\/60759823325\/date-parsing-performance-on-ios-nsdateformatter-vs\">Jens Alfke<\/a>:<\/p>\n<blockquote cite=\"http:\/\/thought-palace.tumblr.com\/post\/60759823325\/date-parsing-performance-on-ios-nsdateformatter-vs\"><p>vombat cleverly discovered that SQLite&rsquo;s strftime function parses ISO-8601 (i.e. JSON) dates an order of magnitude faster than NSDateFormatter does, even with the overhead of having to generate and evaluate a SQL SELECT statement to run it.<\/p>\n<p>I decided to go one step farther &mdash; I tweezed out the ~250 lines of C code from SQLite that implement the actual parsing, and got them to build independently. This adds another factor of 2x speed.<\/p><\/blockquote>\n<p>I enjoy reading the SQLite code. <code>NSDateFormatter<\/code> also seems to be responsible for Numbers&rsquo; horrific performance when opening CSV files.<\/p>","protected":false},"excerpt":{"rendered":"<p>Jens Alfke: vombat cleverly discovered that SQLite&rsquo;s strftime function parses ISO-8601 (i.e. JSON) dates an order of magnitude faster than NSDateFormatter does, even with the overhead of having to generate and evaluate a SQL SELECT statement to run it. I decided to go one step farther &mdash; I tweezed out the ~250 lines of C [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-08-05T20:49:16Z","apple_news_api_id":"c6b3efa3-3519-4027-88a4-21e20f677b6f","apple_news_api_modified_at":"2019-08-05T20:49:17Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AxrPvozUZQCeIpCHiD2d7bw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[45,69,1857,507,568,74,138,270,71,425],"class_list":["post-7810","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-c","tag-cocoa","tag-csv","tag-json","tag-nsdateformatter","tag-opensource","tag-optimization","tag-parser","tag-programming","tag-sqlite"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=7810"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7810\/revisions"}],"predecessor-version":[{"id":7827,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7810\/revisions\/7827"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=7810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=7810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=7810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}