GitHub - igorkasyanchuk/time_m: The easiest way to measure execution time of your code - simple gem to measure the execution of your code.
Just a little bit better than doing “puts Time.now - start”
GitHub - igorkasyanchuk/time_m: The easiest way to measure execution time of your code - simple gem to measure the execution of your code.
Just a little bit better than doing “puts Time.now - start”
IRB has something similar builtin. Rails allows you to do that with Benchmark.measure:
def process
Rails.benchmark("=== Processing invoices ===") do
logger.debug("=== Processing started ===")
process_invoices
logger.debug("=== Processing done ===")
end
end
it will output
Started GET "/companies/1/invoices" for ::1 at 2021-02-24 16:40:35 +0530
Processing by CompaniesController#invoices as HTML
Parameters: {"id"=>"1"}
=== Processing started ===
=== Processing done ===
=== Processing invoices === (400.7ms)
Rendered companies/invoices.html.erb within layouts/application (Duration: 1.1ms | Allocations: 426)
[Webpacker] Everything's up-to-date. Nothing to do
Rendered layout layouts/application.html.erb (Duration: 7.6ms | Allocations: 4025)
Completed 200 OK in 417ms (Views: 8.3ms | ActiveRecord: 0.9ms | Allocations: 7397)
Yes, I know. This is what I used too, but it’s just more code to type. Also it’s less noticeable in the logs