Forum: Ruby Re: Small optimization tips

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-03-14 20:01
(Received via mailing list)
I made a script run 800% faster by using the Time class instead of the
DateTime class.  You can see the scripts and more details at
http://www.recentrambles.com/pragmatic/view/33  Also, using a "memoize"
function whenever possible can greatly increase performance.


I'm still new to ruby, but what does this mean?

On Wed, 2006-03-15 at 03:53 +0900, Vincent Foley wrote:

> * Using a Set instead of an Array when you only want to store unique
> values can help make your code go faster

Charlie Bowman
http://www.recentrambles.com
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-03-14 20:04
(Received via mailing list)
On Mar 14, 2006, at 12:59 PM, Charlie Bowman wrote:

> I'm still new to ruby, but what does this mean?

The Set library is a standard library that comes with Ruby.  I
believe it uses rbtree if it can be loaded or a plain Hash otherwise,
but it supports the expected set operations and keeps the contents
unique.

James Edward Gray II
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-03-14 20:20
(Received via mailing list)
Thanks, I'll look that up in the pickaxe book when I get home.

On Wed, 2006-03-15 at 04:04 +0900, James Edward Gray II wrote:

>
>

Charlie Bowman
Programmer
Castle Branch Inc.
Dbf0c4a1a7eff07c11312673937c45f8?d=identicon&s=25 Vincent Foley (Guest)
on 2006-03-14 20:26
(Received via mailing list)
Ah thanks about the Time class.  The script I wrote deals with dates,
and I was using Date.strptime.  Switching to Time.gm increased the
speed of the script by 4x.
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-03-14 20:57
(Received via mailing list)
On Wed, 15 Mar 2006, James Edward Gray II wrote:

> On Mar 14, 2006, at 12:59 PM, Charlie Bowman wrote:
>
>> I'm still new to ruby, but what does this mean?
>
> The Set library is a standard library that comes with Ruby.  I believe it
> uses rbtree if it can be loaded or a plain Hash otherwise, but it supports
> the expected set operations and keeps the contents unique.

when, oh when, will rbtree be in the core...  sigh.

-a
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2006-03-14 21:15
(Received via mailing list)
ara.t.howard@noaa.gov wrote:
> when, oh when, will rbtree be in the core...  sigh.
>
> -a

and it would be nice for it to have some more methods, like #slice! (a
destructive version of #bound).
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-03-14 21:31
(Received via mailing list)
On Mar 14, 2006, at 1:57 PM, ara.t.howard@noaa.gov wrote:

>
> when, oh when, will rbtree be in the core...  sigh.

Isn't it the library someone was complaining is broken in Ruby
1.8.4?  We might need to fix it first.  <laughs>

James Edward Gray II
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2006-03-14 21:40
(Received via mailing list)
James Edward Gray II wrote:
> Isn't it the library someone was complaining is broken in Ruby 1.8.4?
> We might need to fix it first.  <laughs>

Did you mean ruby-talk:183166 ? I've been using rbtree happily on 1.8.4.
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-03-14 21:47
(Received via mailing list)
On Mar 14, 2006, at 2:39 PM, Joel VanderWerf wrote:

> James Edward Gray II wrote:
>> Isn't it the library someone was complaining is broken in Ruby 1.8.4?
>> We might need to fix it first.  <laughs>
>
> Did you mean ruby-talk:183166 ? I've been using rbtree happily on
> 1.8.4.

Oops, yeah, my memory was poor on that one.  It looks like it might
be broken on 1.8.2, not 1.8.4.  Sorry.  My bad.

James Edward Gray II
This topic is locked and can not be replied to.