Since I'm on windows I'm running this from powershell.
ruby -r profile myprogram.rb 2> prof.log
This will turn on ruby's profiling which writes to STDERR. the 2> catches that output and puts it into a file.
Now after you run this there will be a bunch of noise in your prof.log file, so to remove it just do
gc prof.log | where { $_ -notmatch "^At" } | where { $_ -notmatch "^\+"} > perf.log