Skip to content

Commit

Permalink
Merge pull request rails#57 from johrstrom/rubyprof-update
Browse files Browse the repository at this point in the history
update to use ruby-profy > 1.0.0
  • Loading branch information
rafaelfranca authored Jun 28, 2022
2 parents 92ff7d0 + 21113d3 commit 00adba5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.0.6)
ruby-prof (0.15.7)
ruby-prof (1.4.3)
sqlite3 (1.3.10)
strscan (3.0.1)
thor (1.2.1)
Expand All @@ -116,7 +116,7 @@ DEPENDENCIES
minitest (>= 3)
rails-perftest!
railties (>= 5.2)
ruby-prof (>= 0.12.1)
ruby-prof (>= 1.0.0)
sqlite3 (>= 1.3)

BUNDLED WITH
Expand Down
13 changes: 9 additions & 4 deletions lib/rails/perftest/active_support/testing/performance/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,27 @@ class ProcessTime < Time
Mode = RubyProf::PROCESS_TIME if RubyProf.const_defined?(:PROCESS_TIME)

def measure
RubyProf.measure_process_time
RubyProf.measure_mode = Mode
super
end
end

class WallTime < Time
Mode = RubyProf::WALL_TIME if RubyProf.const_defined?(:WALL_TIME)

def measure
RubyProf.measure_wall_time
RubyProf.measure_mode = Mode
super
end
end

class CpuTime < Time
Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME)
# from ruby-prof changelog: 'Remove the CPU_TIME measurement mode since it duplicates the PROCESS_TIME mode and required inline assembly code'
Mode = RubyProf::PROCESS_TIME if RubyProf.const_defined?(:PROCESS_TIME)

def measure
RubyProf.measure_cpu_time
RubyProf.measure_mode = Mode
super
end
end

Expand All @@ -139,6 +143,7 @@ class Memory < DigitalInformationUnit
# Ruby 1.9 + GCdata patch
if GC.respond_to?(:malloc_allocated_size)
def measure
RubyProf.measure_mode = Mode
GC.malloc_allocated_size
end
end
Expand Down
2 changes: 1 addition & 1 deletion rails-perftest.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'activerecord', '>= 5.2'
gem.add_development_dependency 'minitest', '>= 3'
gem.add_development_dependency 'railties', '>= 5.2'
gem.add_development_dependency 'ruby-prof', '>= 0.12.1'
gem.add_development_dependency 'ruby-prof', '>= 1.0.0'
gem.add_development_dependency 'sqlite3', '>= 1.3'
end
2 changes: 1 addition & 1 deletion rails-perftest.gemspec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = Rails::Perftest::VERSION

gem.add_development_dependency 'ruby-prof', '>= 0.12.1'
gem.add_development_dependency 'ruby-prof', '>= 1.0.0'
gem.add_development_dependency 'minitest', '>= 3'
gem.add_development_dependency 'railties', '~> 4.0'
gem.add_development_dependency 'activerecord', '~> 4.0'
Expand Down

0 comments on commit 00adba5

Please sign in to comment.