Help needed regarding ruby-prof

Hi all, Today I came accross ruby-prof and gave it a try on a simple
program. I have installed the latest ruby-prof gem and patches for ruby.

here is my code:

require ‘rubygems’
require ‘ruby-prof’

RubyProf.measure_mode = RubyProf::ALLOCATIONS
RubyProf.start
for i in 1…10
str = “hello #{i}”
str1 = “world #{i}”
end
result = RubyProf.stop
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT, 0)

gives the output:
Thread ID: 3085010700
Total: 40.000000

%self total self wait child calls name
50.00 40.00 20.00 0.00 20.00 1 Range#each
(ruby_runtime:0}
50.00 20.00 20.00 0.00 0.00 20 Fixnum#to_s
(ruby_runtime:0}
0.00 40.00 0.00 0.00 40.00 0 Global#[No method]
(demo.rb:6}

and now, i replaced the for loop with a while condition as

require ‘rubygems’
require ‘ruby-prof’

RubyProf.measure_mode = RubyProf::ALLOCATIONS
RubyProf.start
i = 0
while i < 10
str = “hello #{i}”
str1 = “world #{i}”
i +=1
end
result = RubyProf.stop
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT, 0)

gives the output:
Thread ID: 3084683020
Total: 20.000000

%self total self wait child calls name
100.00 20.00 20.00 0.00 0.00 20 Fixnum#to_s
(ruby_runtime:0}
0.00 0.00 0.00 0.00 0.00 10 Fixnum#+
(ruby_runtime:0}
0.00 0.00 0.00 0.00 0.00 11 Fixnum#<
(ruby_runtime:0}
0.00 20.00 0.00 0.00 20.00 0 Global#[No method]
(demo1.rb:6}

I have two questions

  1. what makes the diff btwn for and while
  2. how do I get the info regarding allocated memory

I would also be helpful, If anyone could refer a source explaining the
terminology in the output ex: self, total, wait etc…

any help appreciated…

regards,
Venkat