v2.3.8 - Show latest stable - 0 notes - Class: ActiveRecord::Base
benchmark(title, log_level = Logger::DEBUG, use_silence = true) public

Log and benchmark multiple statements in a single block. Example:

  Project.benchmark("Creating project") do
    project = Project.create("name" => "stuff")
    project.create_manager("name" => "David")
    project.milestones << Milestone.find(:all)

The benchmark is only recorded if the current level of the logger is less than or equal to the log_level, which makes it easy to include benchmarking statements in production software that will remain inexpensive because the benchmark will only be conducted if the log level is low enough.

The logging of the multiple statements is turned off unless use_silence is set to false.

Show source
Register or log in to add new notes.