aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/testing/performance.rb6
-rw-r--r--activesupport/lib/active_support/testing/performance/jruby.rb8
-rw-r--r--activesupport/lib/active_support/testing/performance/rubinius.rb8
3 files changed, 14 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/testing/performance.rb b/activesupport/lib/active_support/testing/performance.rb
index 5e9bc40976..598eb330eb 100644
--- a/activesupport/lib/active_support/testing/performance.rb
+++ b/activesupport/lib/active_support/testing/performance.rb
@@ -126,6 +126,12 @@ module ActiveSupport
end
end
+ def time_with_block
+ before = Time.now
+ yield
+ Time.now - before
+ end
+
def run; end
def record; end
end
diff --git a/activesupport/lib/active_support/testing/performance/jruby.rb b/activesupport/lib/active_support/testing/performance/jruby.rb
index 9beadba310..6b27959840 100644
--- a/activesupport/lib/active_support/testing/performance/jruby.rb
+++ b/activesupport/lib/active_support/testing/performance/jruby.rb
@@ -27,11 +27,11 @@ module ActiveSupport
def run
return unless @supported
- @data = JRuby::Profiler.profile do
- full_profile_options[:runs].to_i.times { run_test(@metric, :profile) }
+ @total = time_with_block do
+ @data = JRuby::Profiler.profile do
+ full_profile_options[:runs].to_i.times { run_test(@metric, :profile) }
+ end
end
-
- @total = @data.getDuration / 1000 / 1000 / 1000.0 # seconds
end
def record
diff --git a/activesupport/lib/active_support/testing/performance/rubinius.rb b/activesupport/lib/active_support/testing/performance/rubinius.rb
index fafa782e8d..fbb58a2b3a 100644
--- a/activesupport/lib/active_support/testing/performance/rubinius.rb
+++ b/activesupport/lib/active_support/testing/performance/rubinius.rb
@@ -29,11 +29,11 @@ module ActiveSupport
@profiler = Rubinius::Profiler::Instrumenter.new
- @profiler.profile(false) do
- full_profile_options[:runs].to_i.times { run_test(@metric, :profile) }
+ @total = time_with_block do
+ @profiler.profile(false) do
+ full_profile_options[:runs].to_i.times { run_test(@metric, :profile) }
+ end
end
-
- @total = @profiler.info[:runtime] / 1000 / 1000 / 1000.0 # seconds
end
def record