summaryrefslogtreecommitdiff
path: root/lib/peek
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-06-07 19:55:07 +0200
committerRémy Coutable <remy@rymai.me>2017-06-09 17:21:39 +0200
commite85914532970d61d53f025f3ff0d85891bab2637 (patch)
treea54bac63e63570a31ff31d4cafffc31e1636a1a0 /lib/peek
parent55631e3d52dd2e16b69b02ffc99207b60a22989e (diff)
downloadgitlab-ce-e85914532970d61d53f025f3ff0d85891bab2637.tar.gz
Fix Rubocop offenses, improve SQL duration format and changelog entry
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/peek')
-rw-r--r--lib/peek/rblineprof/custom_controller_helpers.rb30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/peek/rblineprof/custom_controller_helpers.rb b/lib/peek/rblineprof/custom_controller_helpers.rb
index 796420971b5..2ecda58c669 100644
--- a/lib/peek/rblineprof/custom_controller_helpers.rb
+++ b/lib/peek/rblineprof/custom_controller_helpers.rb
@@ -11,6 +11,7 @@ module Peek
end
end
+ # rubocop:disable Metrics/AbcSize
def inject_rblineprof
ret = nil
profile = lineprof(rblineprof_profiler_regex) do
@@ -25,32 +26,43 @@ module Peek
# Sort each file by the longest calculated time
per_file = profile.map do |file, lines|
- total, child, excl, total_cpu, child_cpu, excl_cpu = lines[0]
+ total, _child, excl, total_cpu, _child_cpu, excl_cpu = lines[0]
wall = summary == 'exclusive' ? excl : total
cpu = summary == 'exclusive' ? excl_cpu : total_cpu
idle = summary == 'exclusive' ? (excl - excl_cpu) : (total - total_cpu)
+ sort_method =
+ case sort
+ when 'idle'
+ idle
+ when 'cpu'
+ cpu
+ else
+ wall
+ end
+
[
file, lines,
wall, cpu, idle,
- sort == 'idle' ? idle : sort == 'cpu' ? cpu : wall
+ sort_method
]
- end.sort_by{ |a,b,c,d,e,f| -f }
+ end
+ per_file = per_file.sort_by { |_a, _b, _c, _d, _e, f| -f }
output = ''
per_file.each do |file_name, lines, file_wall, file_cpu, file_idle, file_sort|
-
output << "<div class='peek-rblineprof-file'><div class='heading'>"
show_src = file_sort > min
tmpl = show_src ? "<a href='#' class='js-lineprof-file'>%s</a>" : "%s"
- if mode == 'cpu'
- output << sprintf("<span class='duration'>% 8.1fms + % 8.1fms</span> #{tmpl}", file_cpu / 1000.0, file_idle / 1000.0, file_name.sub(Rails.root.to_s + '/', ''))
- else
- output << sprintf("<span class='duration'>% 8.1fms</span> #{tmpl}", file_wall/1000.0, file_name.sub(Rails.root.to_s + '/', ''))
- end
+ output <<
+ if mode == 'cpu'
+ sprintf("<span class='duration'>% 8.1fms + % 8.1fms</span> #{tmpl}", file_cpu / 1000.0, file_idle / 1000.0, file_name.sub(Rails.root.to_s + '/', ''))
+ else
+ sprintf("<span class='duration'>% 8.1fms</span> #{tmpl}", file_wall / 1000.0, file_name.sub(Rails.root.to_s + '/', ''))
+ end
output << "</div>" # .heading