Eric Sven Ristad <ristad / mnemonic.com> writes:

> It would be great if Ruby would instrument system resources, such as
> user cpu time, system cpu time, current process size, and current
> memory allocation.  Having direct access to these quantities in Ruby
> would be useful both in debugging libraries and benchmarking parts of
> programs in context of actual use.

Have you come across Ruby's profile facility?

    ruby -r profile   xxx.rb

      %   cumulative   self              self     total
     time   seconds   seconds    calls  ms/call  ms/call  name
     22.01     0.35      0.35       10    35.00    56.00  Kernel.require
     13.21     0.56      0.21        1   210.00   550.00  TclTkLib.mainloop
      8.18     0.69      0.13       65     2.00     4.62  TkComm.tk_tcl2ruby
      5.66     0.78      0.09        1    90.00    90.00  TclTkIp#new
      5.66     0.87      0.09      115     0.78     1.91  TkComm.ruby2tcl
      4.40     0.94      0.07      119     0.59     1.01  TkComm._get_eval_string
      4.40     1.01      0.07      684     0.10     0.10  Module#method_added

and so on...

The fun thing is that profile is written in pure Ruby, so if you
wanted to extend it to capture memory usage, number of active objects, 
or whatever, you could do it simply.


Regards


Dave