Charlie Bowman wrote:

>I'm trying to speed up a small app that I've written.  When I run the
>profiler I see that 46% of my applications time is spent on Integer#gcd.
>This seems to be coming from DateTime.  I need to store dates, and then
>find the differences in time between these dates.  Is there anything I
>can do differently or do I just have to suffer the consequences of using
>ruby's DateTime class?
>
>
>example
>
>diff = DateTime.now - data_from_file
>h,m,s,frac = DateTime.day_fraction_to_time(diff)
>
>another example
>
>todays_data << [DateTime.parse(time),status,task.chomp]
>  
>
DateTime, being written in Ruby itself, is pretty slow.  If you can use 
the Time class instead, you will see a significant performance boost, 
since it is written in C.

There is one gotcha about the Time class:  on Windows, you can't create 
a Time object earlier than January 1, 1970 (this is not a limitation on 
*nix).  If this is not an issue for you, you might be able to get away 
with using Time.

Jamey