summaryrefslogtreecommitdiff
path: root/lib/gitlab/profiler.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-03-22 00:27:39 +0000
committerStan Hu <stanhu@gmail.com>2018-03-22 00:27:39 +0000
commitb17457a7f7fb390c829ff5feed7e4635bf2b4521 (patch)
tree8d3e5d2b554993a6c80bc1e7e92622b7d44db145 /lib/gitlab/profiler.rb
parent6ce1013b3f5d72278cb0b829d48a74d00acfa770 (diff)
parente236180618c785ccf210fcf4847242ca814731d3 (diff)
downloadgitlab-ce-b17457a7f7fb390c829ff5feed7e4635bf2b4521.tar.gz
Merge branch 'add-query-counts-to-profiler-output' into 'master'
Add query counts by model to profiler output See merge request gitlab-org/gitlab-ce!17910
Diffstat (limited to 'lib/gitlab/profiler.rb')
-rw-r--r--lib/gitlab/profiler.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb
index 98a168b43bb..18540e64d4c 100644
--- a/lib/gitlab/profiler.rb
+++ b/lib/gitlab/profiler.rb
@@ -92,8 +92,8 @@ module Gitlab
if type && time
@load_times_by_model ||= {}
- @load_times_by_model[type] ||= 0
- @load_times_by_model[type] += time.to_f
+ @load_times_by_model[type] ||= []
+ @load_times_by_model[type] << time.to_f
end
super
@@ -135,8 +135,12 @@ module Gitlab
def self.log_load_times_by_model(logger)
return unless logger.respond_to?(:load_times_by_model)
- logger.load_times_by_model.to_a.sort_by(&:last).reverse.each do |(model, time)|
- logger.info("#{model} total: #{time.round(2)}ms")
+ summarised_load_times = logger.load_times_by_model.to_a.map do |(model, times)|
+ [model, times.count, times.sum]
+ end
+
+ summarised_load_times.sort_by(&:last).reverse.each do |(model, query_count, time)|
+ logger.info("#{model} total (#{query_count}): #{time.round(2)}ms")
end
end
end