Home Resume
Ruby Profiling Notes
ruby -r profile

Perl/DBI Profiling Notes
DBI
DBI::Profile and DBI::ProfileDumper
DBI_PROFILE=1..6 script.pl

Perl
perl -d:DProf
dprofpp <file>

Ruby Determine Platform
puts RUBY_PLATFORM # => 'i386-linux'

or

require 'rbconfig'
puts Config::CONFIG['target_cpu'] # => 'i386'
puts Config::CONFIG['target_os'] # => 'linux'
puts Config::CONFIG['host_cpu'] # => 'i686'
puts Config::CONFIG['host_os'] # => 'linux-gnu'

Ruby Functional Programming Examples
def my_times(n, f)
  if n >= 1
    f.call()
    my_times(n-1, f)
  end
end

my_times(3, proc { puts "testing" } )

times = proc { |n, f|
  if n >= 1
    f.call()
    times.call(n-1, f)
  end
}

times.call(3, proc { puts "hello world" } )
	
puts proc { |n|
  proc { |fact| fact.call(fact, n) }.call(
    proc { |ft, k|
      k <= 1 ? 1 : k * ft.call(ft, k-1)
    }
  )
}.call(10)

proc { |*a|
  proc { |iter| iter.call(iter, *a) }.call(
    proc { |me, n, f|
      if n >= 1
        f.call()
        me.call(me, n-1, f)
      end
    }
  )
}.call(3, proc { puts "hello again" } )