Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-07-19 15:38:57 +0300
committerSean McGivern <sean@gitlab.com>2018-07-19 18:00:27 +0300
commitef973f6f28f5b98ba126985b01d1c463e1cd8761 (patch)
treef5a4a2f1cccfe3946aa65cc5627a86340fe0177f /lib/gitlab/profiler.rb
parent928c81e2598da2a114011549b7aa68fce85fd077 (diff)
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.rb6
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