From: Jeremy Evans Date: 2009-08-18T23:45:19+09:00 Subject: Re: ANN: ThirdBase 1.2.0 Rick Denatale wrote: > Both Date::Performance and ThirdBase seem to focus on the performance > of datetime parsing. ThirdBase doesn't just focus on parsing speed. It also tries to be fast to instantiate and fast for calculations. In addition to performance, ThirdBase also makes the parsers for Date.parse/DateTime.parse easily modifiable for the user. > I took a quick look at the Date::Performance code, and it definitely > is taking the approach of re-implementing a few key methods in C. I > suspect that most of the performance comes from calling the Clib > strptime routine, less so from the 'ruby-inlined' methods. > > In implementing RiCal http://github.com/rubyredrick/ri_cal/tree/master > my main performance problem with datetime was date time calculations. > Because of the standard datetime implementation using a rational > fraction to represent the time-of-day portion of a datetime the > performance profiles were dominated by the gcd calculations needed to > reduce rational numbers. > > So in my case I replaced the internal use of datetime instances with a > custom class which uses a normal Ruby date and a fixnum representing > the number of seconds since the beginning of the day, no C code, all > ruby and much much faster for my purposes. ThirdBase takes a slightly different approach. It stores the date in whatever the input format is, converting only when necessary (which is why it is fast to instantiate). When it does need to do calculations, it generally converts to an integer julian day number and a Float representing the fraction of the day. > But not at all a general replacement for datetime. ThirdBase can be used as a general replacement. Not everything works the same way, but the differences are documented and won't affect most code. Jeremy -- Posted via http://www.ruby-forum.com/.