diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/benchmark.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/benchmark.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/benchmark.rb b/activesupport/lib/active_support/core_ext/benchmark.rb new file mode 100644 index 0000000000..641b58c8b8 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/benchmark.rb @@ -0,0 +1,16 @@ +# 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 |