diff options
author | Sean McGivern <sean@gitlab.com> | 2018-07-19 13:38:57 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-07-19 16:00:27 +0100 |
commit | ef973f6f28f5b98ba126985b01d1c463e1cd8761 (patch) | |
tree | f5a4a2f1cccfe3946aa65cc5627a86340fe0177f /lib/gitlab/profiler.rb | |
parent | 928c81e2598da2a114011549b7aa68fce85fd077 (diff) | |
download | gitlab-ce-ef973f6f28f5b98ba126985b01d1c463e1cd8761.tar.gz |
Add a Gitlab::Profiler.print_by_total_time convenience method
This method uses Gitlab::Profiler::TotalTimeFlatPrinter internally, which is the
same as RubyProf::FlatPrinter, but the min_percent option (and new max_percent
option) applies to the _total_ time, not the _self_ time. This helps us figure
out if we're calling a library inefficiently, for instance.
Diffstat (limited to 'lib/gitlab/profiler.rb')
-rw-r--r-- | lib/gitlab/profiler.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb index ecff6ab5d5e..c5bb4648572 100644 --- a/lib/gitlab/profiler.rb +++ b/lib/gitlab/profiler.rb @@ -146,5 +146,11 @@ module Gitlab logger.info("#{model} total (#{query_count}): #{time.round(2)}ms") end end + + def self.print_by_total_time(result, options = {}) + default_options = { sort_method: :total_time } + + Gitlab::Profiler::TotalTimeFlatPrinter.new(result).print(STDOUT, default_options.merge(options)) + end end end |