30x faster JSON date parsing

2013-09-09 Thread Jens Alfke
Parsing dates from strings can be surprisingly expensive — more than once I’ve seen it show up as the primary hot-spot in code that reads files or parses network data. NSDateFormatter is very flexible, but you pay for that in speed. If you only need to parse a single simple date/time format you

Re: 30x faster JSON date parsing

2013-09-09 Thread Maxthon Chan
This may not be that useful in all circumstances - I always send dates as milliseconds since the UNIX epoch as 64-bit signed integers. Those are *way* faster to parse. On Sep 10, 2013, at 0:11, Jens Alfke j...@mooseyard.com wrote: Parsing dates from strings can be surprisingly expensive — more

Re: 30x faster JSON date parsing

2013-09-09 Thread Jean-Daniel Dupas
Le 9 sept. 2013 à 18:11, Jens Alfke j...@mooseyard.com a écrit : Parsing dates from strings can be surprisingly expensive — more than once I’ve seen it show up as the primary hot-spot in code that reads files or parses network data. NSDateFormatter is very flexible, but you pay for that

Re: 30x faster JSON date parsing

2013-09-09 Thread Marcel Weiher
Hi Jens, Premature optimization is the root of all evil! Er, I misspelled: “very cool, nice job!” On Sep 9, 2013, at 18:11 , Jens Alfke j...@mooseyard.com wrote: [..] [fg160,160,160;16:34:40.488| [fg0,128,0;[;NSDateFormatter took 26.97 µsec [fg160,160,160;16:34:48.649|

Re: 30x faster JSON date parsing

2013-09-09 Thread Marcel Weiher
On Sep 9, 2013, at 19:05 , Jean-Daniel Dupas devli...@shadowlab.org wrote: Le 9 sept. 2013 à 18:11, Jens Alfke j...@mooseyard.com a écrit : [fg160,160,160;16:34:40.488| [fg0,128,0;[;NSDateFormatter took 26.97 µsec [fg160,160,160;16:34:48.649| [fg0,128,0;[;CBLParseDatetook

Re: 30x faster JSON date parsing

2013-09-09 Thread Marcel Weiher
On Sep 9, 2013, at 19:20 , Tito Ciuro tci...@mac.com wrote: On Sep 9, 2013, at 10:14 AM, Marcel Weiher marcel.wei...@gmail.com wrote: Premature optimization is the root of all evil! What's premature about it? Nothing: Er, I misspelled: “very cool, nice job!” :-) Marcel

Re: 30x faster JSON date parsing

2013-09-09 Thread Tito Ciuro
What's premature about it? -- Tito On Sep 9, 2013, at 10:14 AM, Marcel Weiher marcel.wei...@gmail.com wrote: Hi Jens, Premature optimization is the root of all evil! Er, I misspelled: “very cool, nice job!” On Sep 9, 2013, at 18:11 , Jens Alfke j...@mooseyard.com wrote: [..]

Re: 30x faster JSON date parsing

2013-09-09 Thread Marcel Weiher
On Sep 9, 2013, at 19:35 , Jens Alfke j...@mooseyard.com wrote: On Sep 9, 2013, at 10:14 AM, Marcel Weiher marcel.wei...@gmail.com wrote: Premature optimization is the root of all evil! I’m not sure if you meant that ironically, but it’s absolutely not premature. Absolutely! On both

Re: 30x faster JSON date parsing

2013-09-09 Thread Jens Alfke
On Sep 9, 2013, at 10:14 AM, Marcel Weiher marcel.wei...@gmail.com wrote: Premature optimization is the root of all evil! I’m not sure if you meant that ironically, but it’s absolutely not premature. I’ve run into major NSDateFormatter bottlenecks — as in “hm, over half the time to open this

Re: 30x faster JSON date parsing

2013-09-09 Thread Scott Ribe
On Sep 9, 2013, at 11:35 AM, Jens Alfke j...@mooseyard.com wrote: I’m not sure if you meant that ironically, but it’s absolutely not premature. I’ve run into major NSDateFormatter bottlenecks — as in “hm, over half the time to open this file is spent inside NSDateFormatter” — at least twice,

Re: 30x faster JSON date parsing

2013-09-09 Thread Jens Alfke
On Sep 9, 2013, at 10:48 AM, Jeffrey Oleander jgo...@yahoo.com wrote: The issue is users entering dates […] am sorely wishing I could just enforce ISO date entry as in the quoted example by using pop-up menus. Some do, but the dread of customer rebellion is strong, and they want to enter

Re: 30x faster JSON date parsing

2013-09-09 Thread Rick Mann
On Sep 9, 2013, at 09:25 , Maxthon Chan xcvi...@me.com wrote: This may not be that useful in all circumstances - I always send dates as milliseconds since the UNIX epoch as 64-bit signed integers. Those are *way* faster to parse. Yes. It's ridiculous that a lot of JSON APIs send ISO

Re: 30x faster JSON date parsing

2013-09-09 Thread Marcel Weiher
Just to add a tiny wrinkle: On Sep 9, 2013, at 20:27 , Jens Alfke j...@mooseyard.com wrote: On Sep 9, 2013, at 10:48 AM, Jeffrey Oleander jgo...@yahoo.com wrote: [..] Some do, but the dread of customer rebellion is strong, and they want to enter them in the slap-dash, hurried, harried ways

Re: 30x faster JSON date parsing

2013-09-09 Thread Tom Davie
On 9 Sep 2013, at 20:29, Rick Mann rm...@latencyzero.com wrote: On Sep 9, 2013, at 09:25 , Maxthon Chan xcvi...@me.com wrote: This may not be that useful in all circumstances - I always send dates as milliseconds since the UNIX epoch as 64-bit signed integers. Those are *way* faster to

Re: 30x faster JSON date parsing

2013-09-09 Thread Rick Mann
On Sep 9, 2013, at 11:46 , Tom Davie tom.da...@gmail.com wrote: On 9 Sep 2013, at 20:29, Rick Mann rm...@latencyzero.com wrote: On Sep 9, 2013, at 09:25 , Maxthon Chan xcvi...@me.com wrote: This may not be that useful in all circumstances - I always send dates as milliseconds since

Re: 30x faster JSON date parsing

2013-09-09 Thread Dave Keck
I’m not sure if you meant that ironically, but it’s absolutely not premature. I’ve run into major NSDateFormatter bottlenecks — as in “hm, over half the time to open this file is spent inside NSDateFormatter” — at least twice, and the author of the blog post I linked to says that he also

Re: 30x faster JSON date parsing

2013-09-09 Thread Jeffrey Oleander
On 2013 Sep 09, at 13:14, Marcel Weiher wrote: On 2013 Sep 9, at 18:11 , Jens Alfke j...@mooseyard.com wrote: [...] [fg160,160,160;16:34:40.488| [fg0,128,0;[;NSDateFormatter took 26.97 µsec [fg160,160,160;16:34:48.649| [fg0,128,0;[;CBLParseDatetook 0.47 µsec (58x) Now, the