Permalink
Browse files

Don't assume RubyProf constants are defined

  • Loading branch information...
1 parent 161ab28 commit 8d24a029df47fa9ad36f0e027d3cd447f92af344 @jeremy jeremy committed Jun 20, 2008
Showing with 5 additions and 5 deletions.
  1. +5 −5 activesupport/lib/active_support/testing/performance.rb
@@ -288,7 +288,7 @@ def measure
end
class CpuTime < Time
- Mode = RubyProf::CPU_TIME
+ Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME)
def initialize(*args)
# FIXME: yeah my CPU is 2.33 GHz
@@ -302,7 +302,7 @@ def measure
end
class Memory < Base
- Mode = RubyProf::MEMORY
+ Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY)
# ruby-prof wrapper
if RubyProf.respond_to?(:measure_memory)
@@ -335,7 +335,7 @@ def format(measurement)
end
class Objects < Base
- Mode = RubyProf::ALLOCATIONS
+ Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS)
if RubyProf.respond_to?(:measure_allocations)
def measure
@@ -353,7 +353,7 @@ def format(measurement)
end
class GcRuns < Base
- Mode = RubyProf::GC_RUNS
+ Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS)
if RubyProf.respond_to?(:measure_gc_runs)
def measure
@@ -375,7 +375,7 @@ def format(measurement)
end
class GcTime < Base
- Mode = RubyProf::GC_TIME
+ Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
if RubyProf.respond_to?(:measure_gc_time)
def measure

0 comments on commit 8d24a02

Please sign in to comment.