2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pry でサクッとベンチマーク

Last updated at Posted at 2021-09-30

.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)
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?