aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/benchmark.rb
blob: 2db6e5f1c5f13c0474936c27bf5e8d5c581d1ea6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true
require "benchmark"

class << Benchmark
  # Benchmark realtime in milliseconds.
  #
  #   Benchmark.realtime { User.all }
  #   # => 8.0e-05
  #
  #   Benchmark.ms { User.all }
  #   # => 0.074
  def ms
    1000 * realtime { yield }
  end
end