If you are using *nix (unix, linux) then you can run "time <ruby 
program>" at the command line.  This might work with Macs as well 
because they are based on unix but I don't have one so I'm not sure.

 From within Ruby, you can do this:
require 'benchmark'

puts Benchmark.measure do
  # program code here.
end

I agree that this was one of the best Ruby Quizzes.  It is simple and 
yet has different, but equally good, types of solutions (regex, sets, 
etc.).  I also enjoyed the opportunity to explore sets and things; more 
RQs that can involve the standard library would be awesome.

Dan

Jason Mayer wrote:
> On 1/9/07, Daniel Finnie <danfinnie / optonline.net> wrote:
>>
>>
>> One thing I can see to optimize in your method is all the sorting.  I
>> haven't tested the performance yet, but sets might be the answer.
>>
>> require 'set'
>>
>> class String
>>         def letters
>>                 split(//).to_set
>>         end
>> end
>>
>> baseWordSet = baseWord.letters
>> dict.select {|x| x.letters.subset?(baseWordSet)}
>>
>> It's more readable, IMHO, at least.
>>
>> Dan
> 
> 
> I used sets in my submission, and the letters of each 6 letter word were
> split in the above fashion so as to provide faster scanning (at least
> according to one of the books I was reading the night before - please
> correct me if I'm wrong).  The answers to these questions was actually what
> I was hoping to hear when I said any feedback would be appreciated :)
> 
> And yes, it's definitely more readable - I wrestled with the idea of how to
> see if one array was a subset of another (and which way was more efficient)
> when I came across the concept of a set for the first time.  s2.subset?(s1)
> sure made life easy and using it made it a lot easier to understand what my
> code was doing just by reading it.
> 
> One last question, which I've been thinking about but not able to 
> dedicate a
> lot of time to is this: how do you 'benchmark' the speed of individual
> programs?  I've been wondering how fast my program is compared to others
> since I wrote it.
> 
> And finally, here's to you, Mr. Ruby Quiz creator guy, for coming up with a
> Ruby quiz that really peaked my interest :)
>