diff --git a/Gemfile b/Gemfile index e70e64c08754f4ea29d1c26bdaedb997a7a0a340..414a8a6774430d5306ef2a9e225e4878df98dee1 100644 --- a/Gemfile +++ b/Gemfile @@ -425,7 +425,7 @@ gem 'gitlab-mail_room', '~> 0.0.3', require: 'mail_room' gem 'email_reply_trimmer', '~> 0.1' gem 'html2text' -gem 'ruby-prof', '~> 1.0.0' +gem 'ruby-prof', '~> 1.3.0' gem 'stackprof', '~> 0.2.15', require: false gem 'rbtrace', '~> 0.4', require: false gem 'memory_profiler', '~> 0.9', require: false diff --git a/Gemfile.lock b/Gemfile.lock index e96a38ccf22ff0dbb4b56342a6def239b2e4b920..bb64fb09649fd489d77312017ffd8a3858c81070 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -951,7 +951,7 @@ GEM i18n ruby-fogbugz (0.2.1) crack (~> 0.4) - ruby-prof (1.0.0) + ruby-prof (1.3.1) ruby-progressbar (1.10.1) ruby-saml (1.7.2) nokogiri (>= 1.5.10) @@ -1358,7 +1358,7 @@ DEPENDENCIES rubocop-performance (~> 1.4.1) rubocop-rspec (~> 1.37.0) ruby-fogbugz (~> 0.2.1) - ruby-prof (~> 1.0.0) + ruby-prof (~> 1.3.0) ruby-progressbar ruby_parser (~> 3.8) rubyzip (~> 2.0.0) diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb index e10cdf0d8fbddf191d9d698747140ba5ce3646cc..42f43f998c490fc77b33e077f8d8d337e18a97e7 100644 --- a/lib/gitlab/profiler.rb +++ b/lib/gitlab/profiler.rb @@ -168,9 +168,9 @@ def self.log_load_times_by_model(logger) # rubocop: enable CodeReuse/ActiveRecord def self.print_by_total_time(result, options = {}) - default_options = { sort_method: :total_time } + default_options = { sort_method: :total_time, filter_by: :total_time } - Gitlab::Profiler::TotalTimeFlatPrinter.new(result).print(STDOUT, default_options.merge(options)) + RubyProf::FlatPrinter.new(result).print(STDOUT, default_options.merge(options)) end end end diff --git a/lib/gitlab/profiler/total_time_flat_printer.rb b/lib/gitlab/profiler/total_time_flat_printer.rb deleted file mode 100644 index 9846bad3c0818d5962934a1222d16655d25869f4..0000000000000000000000000000000000000000 --- a/lib/gitlab/profiler/total_time_flat_printer.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Profiler - class TotalTimeFlatPrinter < RubyProf::FlatPrinter - def max_percent - @options[:max_percent] || 100 - end - - # Copied from: - # <https://github.com/ruby-prof/ruby-prof/blob/master/lib/ruby-prof/printers/flat_printer.rb> - # - # The changes are just to filter by total time, not self time, and add a - # max_percent option as well. - def print_methods(thread) - total_time = thread.total_time - methods = thread.methods.sort_by(&sort_method).reverse - - sum = 0 - methods.each do |method| - total_percent = (method.total_time / total_time) * 100 - next if total_percent < min_percent - next if total_percent > max_percent - - sum += method.self_time - - @output << "%6.2f %9.3f %9.3f %9.3f %9.3f %8d %s%-30s %s\n" % [ - method.self_time / total_time * 100, # %self - method.total_time, # total - method.self_time, # self - method.wait_time, # wait - method.children_time, # children - method.called, # calls - method.recursive? ? "*" : " ", # cycle - method.full_name, # method_name - method_location(method) # location - ] - end - end - end - end -end