run ruby-prof with a script that takes arguments

184 Views Asked by At

I know how to start ruby-prof with a script:

 ruby-prof -p multi [SCRIPT_PATH]/my_script.rb

but how can I run ruby-prof with a script that takes arguments ?

1

There are 1 best solutions below

1
brainbag On BEST ANSWER

Most commands that run another command will let you do this with the special double dash -- option, followed by the arguments you want to pass through. ruby-prof follows this norm.

If you have a Ruby file like this:

# test.rb
puts "ARGV: #{ARGV.inspect}"

You can run ruby-prof like this and get the args:

» ruby-prof test.rb -- arg1 arg2
ARGV: ["arg1", "arg2"]

So in your specific case, you can do this:

» ruby-prof -p multi [SCRIPT_PATH]/my_script.rb -- arg1 arg2