Here is how you can measure and log the time of a block:
require 'elapsed'
elapsed do
run_something_slow
endYou can also send the log message to a log, for example to the Loog:
require 'elapsed'
require 'loog'
elapsed(Loog::VERBOSE) do
# any code
endYou can also make the message custom:
elapsed(intro: 'File saved') do
File.save(f, 'Hello, world!')
endOr, you can make the message even more custom:
elapsed do
File.save(f, 'Hello, world!')
throw :"Successfully saved #{File.size(f)} bytes"
endThat's it.
Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 3.0+ and Bundler installed. Then:
bundle update
bundle exec rakeIf it's clean and you don't see any error messages, submit your pull request.