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.
Charlie B. (Guest)
on 2006-03-14 21: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 F. wrote:

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

Charlie B.
http://www.recentrambles.com
James G. (Guest)
on 2006-03-14 21:04
(Received via mailing list)
On Mar 14, 2006, at 12:59 PM, Charlie B. 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 G. II
Charlie B. (Guest)
on 2006-03-14 21: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 G. II wrote:

>
>

Charlie B.
Programmer
Castle Branch Inc.
Vincent F. (Guest)
on 2006-03-14 21: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.
unknown (Guest)
on 2006-03-14 21:57
(Received via mailing list)
On Wed, 15 Mar 2006, James Edward G. II wrote:

> On Mar 14, 2006, at 12:59 PM, Charlie B. 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
Joel VanderWerf (Guest)
on 2006-03-14 22:15
(Received via mailing list)
removed_email_address@domain.invalid 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).
James G. (Guest)
on 2006-03-14 22:31
(Received via mailing list)
On Mar 14, 2006, at 1:57 PM, removed_email_address@domain.invalid 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 G. II
Joel VanderWerf (Guest)
on 2006-03-14 22:40
(Received via mailing list)
James Edward G. 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.
James G. (Guest)
on 2006-03-14 22:47
(Received via mailing list)
On Mar 14, 2006, at 2:39 PM, Joel VanderWerf wrote:

> James Edward G. 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 G. II
This topic is locked and can not be replied to.