Apologies, cause I’m trying to wrap my brain around this code and I have
some questions about it.
1- It seems that until ‘block.call’ what is getting passed into the
parameters is being held in que (so to speak). Or is that a wrong
2- How does the method know that it calls ‘25000 doublings’ first and
moves on to ‘count to a million’. I realize part of it is how the code
layed out but why couldn’t it just try the 25000 doublings again ?
Hope these type of questions are okay here.
def profile block_description, &block
start_time = Time.now
duration = Time.now - start_time
puts block_description+’ : ’ +duration.to_s+’ seconds’
profile ‘25000 doublings’ do
number = 1
number = number + number
puts number.to_s.length.to_s+’ digits’
That’s the number of digits in this HUGE number.
profile ‘count to a million’ do
number = 0
number = number + 1