thanks for your help - I had forgotten to include benchmark inside
quotes so it wasn't picking it up.
one more quick question...
require'benchmark'
iterations = 100000
a=Benchmark.measure do
for i in 1..iterations do
x=i
end
end
In the above code (from Beginning Ruby book)
what's the difference between benchmark and Benchmark(uppercase)
Also why 2 periods 1..iterations?
The name benchmark is the name of the file to load which in this case
contains the definition of the Benchmark class/module. Until you load
the benchmark file, the Benchmark class/module does not exist in your
Ruby session. Benchmark is uppercase because as a class or module it is
a constant, and Ruby requires that constants' names begin with upper
case letters.
The 1..iterations statement defines a Range object from 1 to the value
of iterations (100000 in this case). The for statement iterates through
that range, setting i to each value and calling the block each time.
There is a similar statement, 1...iterations (note the 3 dots), that
also defines a Range object. The .. form creates an inclusive range
while the ... form creates an exclusive range from 1 to iterations - 1:
(1..2).to_a.last #=> 2
(1...2).to_a.last #=> 1
-Jeremy