Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
be0a949a
Commit
be0a949a
authored
Jun 09, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRYed peek-pg/mysql2 views and update peek-rblineprof monkey-patch file
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
ef4ccb7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
47 deletions
+33
-47
app/views/peek/views/_mysql2.html.haml
app/views/peek/views/_mysql2.html.haml
+3
-13
app/views/peek/views/_pg.html.haml
app/views/peek/views/_pg.html.haml
+3
-13
app/views/peek/views/_sql.html.haml
app/views/peek/views/_sql.html.haml
+13
-0
lib/peek/rblineprof/custom_controller_helpers.rb
lib/peek/rblineprof/custom_controller_helpers.rb
+14
-21
No files found.
app/views/peek/views/_mysql2.html.haml
View file @
be0a949a
%strong
%a
#peek-show-queries
{
href:
'#'
}
%span
{
data:
{
defer_to:
"#{view.defer_key}-duration"
}
}
...
\/
%span
{
data:
{
defer_to:
"#{view.defer_key}-calls"
}
}
...
#modal-peek-pg-queries
.modal
{
tabindex:
-
1
}
.modal-dialog
#modal-peek-pg-queries-content
.modal-content
.modal-header
%a
.close
{
href:
"#"
,
"data-dismiss"
=>
"modal"
}
×
%h4
SQL queries
.modal-body
{
data:
{
defer_to:
"#{view.defer_key}-queries"
}
}
...
-
local_assigns
.
fetch
(
:view
)
=
render
'peek/views/sql'
,
view:
view
mysql
app/views/peek/views/_pg.html.haml
View file @
be0a949a
%strong
%a
#peek-show-queries
{
href:
'#'
}
%span
{
data:
{
defer_to:
"#{view.defer_key}-duration"
}
}
...
\/
%span
{
data:
{
defer_to:
"#{view.defer_key}-calls"
}
}
...
#modal-peek-pg-queries
.modal
{
tabindex:
-
1
}
.modal-dialog
#modal-peek-pg-queries-content
.modal-content
.modal-header
%a
.close
{
href:
"#"
,
"data-dismiss"
=>
"modal"
}
×
%h4
SQL queries
.modal-body
{
data:
{
defer_to:
"#{view.defer_key}-queries"
}
}
...
-
local_assigns
.
fetch
(
:view
)
=
render
'peek/views/sql'
,
view:
view
pg
app/views/peek/views/_sql.html.haml
0 → 100644
View file @
be0a949a
%strong
%a
#peek-show-queries
{
href:
'#'
}
%span
{
data:
{
defer_to:
"#{view.defer_key}-duration"
}
}
...
\/
%span
{
data:
{
defer_to:
"#{view.defer_key}-calls"
}
}
...
#modal-peek-pg-queries
.modal
{
tabindex:
-
1
}
.modal-dialog
#modal-peek-pg-queries-content
.modal-content
.modal-header
%a
.close
{
href:
"#"
,
"data-dismiss"
=>
"modal"
}
×
%h4
SQL queries
.modal-body
{
data:
{
defer_to:
"#{view.defer_key}-queries"
}
}
...
lib/peek/rblineprof/custom_controller_helpers.rb
View file @
be0a949a
...
...
@@ -3,6 +3,8 @@ module Peek
module
CustomControllerHelpers
extend
ActiveSupport
::
Concern
# This will become useless once https://github.com/peek/peek-rblineprof/pull/5
# is merged
def
pygmentize
(
file_name
,
code
,
lexer
=
nil
)
if
lexer
.
present?
Gitlab
::
Highlight
.
highlight
(
file_name
,
code
)
...
...
@@ -11,7 +13,7 @@ module Peek
end
end
# rubocop:disable
Metrics/AbcSize
# rubocop:disable
all
def
inject_rblineprof
ret
=
nil
profile
=
lineprof
(
rblineprof_profiler_regex
)
do
...
...
@@ -26,43 +28,32 @@ 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
_method
sort
==
'idle'
?
idle
:
sort
==
'cpu'
?
cpu
:
wall
]
end
per_file
=
per_file
.
sort_by
{
|
_a
,
_b
,
_c
,
_d
,
_e
,
f
|
-
f
}
end
.
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"
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
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
<<
"</div>"
# .heading
...
...
@@ -89,6 +80,8 @@ module Peek
output
<<
"<pre class='duration'>
#{
times
.
join
(
"
\n
"
)
}
</pre>"
# The following line was changed from
# https://github.com/peek/peek-rblineprof/blob/8d3b7a283a27de2f40abda45974516693d882258/lib/peek/rblineprof/controller_helpers.rb#L125
# This will become useless once https://github.com/peek/peek-rblineprof/pull/16
# is merged and is implemented.
output
<<
"<pre class='code highlight white'>
#{
pygmentize
(
file_name
,
code
.
join
,
'ruby'
)
}
</pre>"
output
<<
"</div></div>"
# .data then .peek-rblineprof-file
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment