Francis Hwang
5/26/2006 11:52:00 AM
So I'm moving an old piece of software of mine to be Rake-specific for
a number of reasons, and I'm trying to record execution time elegantly.
I've got two tasks, and I'd like to be able to enclose the whole thing
in a yielded block.
For example, before Rake the whole thing looked like this:
def profile
start_time = Time.now
yield
total = Time.now - start_time
puts "That took #{ total } seconds."
end
profile do
step1
step2
end
Now, my Rake tasks look like:
task :step2 => :step1 do
...
end
task :step1 do
...
end
Which I like, but leaves me wondering if there's an elegant way to
record the execution time of :step1 then :step2. (Maybe this is a
strange request because in theory :step1 might've already been
executed, though in this case it's really not likely.)
I mean, I could just record a global $start_time variable, sure. That's
no fun, though.
Francis