.pryrc
に以下を追記すると、pry実行時にサクッとベンチマークがとれます。
# ■ 使い方
# pry(main)> bench | { [測定対象] }
# pry(main)> bench | do
# [測定対象]
# end
command_set = Pry::CommandSet.new do
block_command('bench', "Use the Ruby benchmark to measure code blocks.", takes_block: true) do
require 'benchmark'
Benchmark.bm do |x|
x.report do
command_block.call
end
end
end
end
Pry::Commands.import(command_set)