Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e8591453
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e8591453
编写于
6月 07, 2017
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Rubocop offenses, improve SQL duration format and changelog entry
Signed-off-by:
N
Rémy Coutable
<
remy@rymai.me
>
上级
55631e3d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
53 addition
and
63 deletion
+53
-63
app/assets/javascripts/peek.js
app/assets/javascripts/peek.js
+12
-15
app/assets/javascripts/shortcuts.js
app/assets/javascripts/shortcuts.js
+2
-3
changelogs/unreleased/29010-perf-bar.yml
changelogs/unreleased/29010-perf-bar.yml
+1
-1
config/initializers/peek.rb
config/initializers/peek.rb
+3
-3
lib/gitlab/performance_bar/peek_query_tracker.rb
lib/gitlab/performance_bar/peek_query_tracker.rb
+2
-1
lib/peek/rblineprof/custom_controller_helpers.rb
lib/peek/rblineprof/custom_controller_helpers.rb
+21
-9
vendor/assets/javascripts/peek.js
vendor/assets/javascripts/peek.js
+8
-22
vendor/assets/stylesheets/peek.scss
vendor/assets/stylesheets/peek.scss
+4
-9
未找到文件。
app/assets/javascripts/peek.js
浏览文件 @
e8591453
import
'
vendor/peek
'
;
import
'
vendor/peek
'
;
import
'
vendor/peek.performance_bar
'
;
import
'
vendor/peek.performance_bar
'
;
(
function
()
{
$
(
document
).
on
(
'
click
'
,
'
#peek-show-queries
'
,
function
(
e
)
{
$
(
document
).
on
(
'
click
'
,
'
#peek-show-queries
'
,
function
(
e
)
{
e
.
preventDefault
();
var
$modal
;
$
(
'
.peek-rblineprof-modal
'
).
hide
();
$
(
'
.peek-rblineprof-modal
'
).
hide
();
let
$modal
=
$
(
'
#modal-peek-pg-queries
'
);
$modal
=
$
(
'
#modal-peek-pg-queries
'
);
if
(
$modal
.
length
)
{
if
(
$modal
.
length
)
{
$modal
.
modal
(
'
toggle
'
);
$modal
.
modal
(
'
toggle
'
);
}
}
});
return
e
.
preventDefault
();
});
$
(
document
).
on
(
'
click
'
,
'
.js-lineprof-file
'
,
function
(
e
)
{
$
(
document
).
on
(
'
click
'
,
'
.js-lineprof-file
'
,
function
(
e
)
{
$
(
this
).
parents
(
'
.heading
'
).
next
(
'
div
'
).
toggle
();
e
.
preventDefault
();
return
e
.
preventDefault
();
$
(
this
).
parents
(
'
.heading
'
).
next
(
'
div
'
).
toggle
();
});
});
}).
call
(
window
);
app/assets/javascripts/shortcuts.js
浏览文件 @
e8591453
...
@@ -60,11 +60,10 @@ import findAndFollowLink from './shortcuts_dashboard_navigation';
...
@@ -60,11 +60,10 @@ import findAndFollowLink from './shortcuts_dashboard_navigation';
e
.
preventDefault
();
e
.
preventDefault
();
if
(
Cookies
.
get
(
'
perf_bar_enabled
'
)
===
'
true
'
)
{
if
(
Cookies
.
get
(
'
perf_bar_enabled
'
)
===
'
true
'
)
{
Cookies
.
remove
(
'
perf_bar_enabled
'
,
{
path
:
'
/
'
});
Cookies
.
remove
(
'
perf_bar_enabled
'
,
{
path
:
'
/
'
});
}
}
else
{
else
{
Cookies
.
set
(
'
perf_bar_enabled
'
,
true
,
{
path
:
'
/
'
});
Cookies
.
set
(
'
perf_bar_enabled
'
,
true
,
{
path
:
'
/
'
});
}
}
return
gl
.
utils
.
refreshCurrentPage
();
gl
.
utils
.
refreshCurrentPage
();
};
};
Shortcuts
.
prototype
.
toggleMarkdownPreview
=
function
(
e
)
{
Shortcuts
.
prototype
.
toggleMarkdownPreview
=
function
(
e
)
{
...
...
changelogs/unreleased/29010-perf-bar.yml
浏览文件 @
e8591453
---
---
title
:
A
llow to enable a performance bar with the keyboard shortcut
title
:
A
dd an optional performance bar to view performance metrics for the current page
merge_request
:
11439
merge_request
:
11439
author
:
author
:
config/initializers/peek.rb
浏览文件 @
e8591453
...
@@ -3,16 +3,15 @@ Rails.application.config.peek.adapter = :redis, { client: ::Redis.new(Gitlab::Re
...
@@ -3,16 +3,15 @@ Rails.application.config.peek.adapter = :redis, { client: ::Redis.new(Gitlab::Re
Peek
.
into
Peek
::
Views
::
Host
Peek
.
into
Peek
::
Views
::
Host
Peek
.
into
Peek
::
Views
::
PerformanceBar
Peek
.
into
Peek
::
Views
::
PerformanceBar
if
Gitlab
::
Database
.
mysql?
if
Gitlab
::
Database
.
mysql?
require
'peek-mysql'
require
'peek-mysql
2
'
PEEK_DB_CLIENT
=
::
Mysql2
::
Client
PEEK_DB_CLIENT
=
::
Mysql2
::
Client
PEEK_DB_VIEW
=
Peek
::
Views
::
Mysql2
PEEK_DB_VIEW
=
Peek
::
Views
::
Mysql2
Peek
.
into
PEEK_DB_VIEW
else
else
require
'peek-pg'
require
'peek-pg'
PEEK_DB_CLIENT
=
::
PG
::
Connection
PEEK_DB_CLIENT
=
::
PG
::
Connection
PEEK_DB_VIEW
=
Peek
::
Views
::
PG
PEEK_DB_VIEW
=
Peek
::
Views
::
PG
Peek
.
into
PEEK_DB_VIEW
end
end
Peek
.
into
PEEK_DB_VIEW
Peek
.
into
Peek
::
Views
::
Redis
Peek
.
into
Peek
::
Views
::
Redis
Peek
.
into
Peek
::
Views
::
Sidekiq
Peek
.
into
Peek
::
Views
::
Sidekiq
Peek
.
into
Peek
::
Views
::
Rblineprof
Peek
.
into
Peek
::
Views
::
Rblineprof
...
@@ -25,4 +24,5 @@ class PEEK_DB_CLIENT
...
@@ -25,4 +24,5 @@ class PEEK_DB_CLIENT
self
.
query_details
=
Concurrent
::
Array
.
new
self
.
query_details
=
Concurrent
::
Array
.
new
end
end
# rubocop:disable Style/ClassAndModuleCamelCase
PEEK_DB_VIEW
.
prepend
::
Gitlab
::
PerformanceBar
::
PeekQueryTracker
PEEK_DB_VIEW
.
prepend
::
Gitlab
::
PerformanceBar
::
PeekQueryTracker
lib/gitlab/performance_bar/peek_query_tracker.rb
浏览文件 @
e8591453
...
@@ -30,7 +30,8 @@ module Gitlab
...
@@ -30,7 +30,8 @@ module Gitlab
def
track_query
(
raw_query
,
bindings
,
start
,
finish
)
def
track_query
(
raw_query
,
bindings
,
start
,
finish
)
query
=
Gitlab
::
Sherlock
::
Query
.
new
(
raw_query
,
start
,
finish
)
query
=
Gitlab
::
Sherlock
::
Query
.
new
(
raw_query
,
start
,
finish
)
query_info
=
{
duration:
query
.
duration
.
round
(
4
),
sql:
query
.
formatted_query
}
query_info
=
{
duration:
'%.3f'
%
query
.
duration
,
sql:
query
.
formatted_query
}
PEEK_DB_CLIENT
.
query_details
<<
query_info
PEEK_DB_CLIENT
.
query_details
<<
query_info
end
end
end
end
...
...
lib/peek/rblineprof/custom_controller_helpers.rb
浏览文件 @
e8591453
...
@@ -11,6 +11,7 @@ module Peek
...
@@ -11,6 +11,7 @@ module Peek
end
end
end
end
# rubocop:disable Metrics/AbcSize
def
inject_rblineprof
def
inject_rblineprof
ret
=
nil
ret
=
nil
profile
=
lineprof
(
rblineprof_profiler_regex
)
do
profile
=
lineprof
(
rblineprof_profiler_regex
)
do
...
@@ -25,32 +26,43 @@ module Peek
...
@@ -25,32 +26,43 @@ module Peek
# Sort each file by the longest calculated time
# Sort each file by the longest calculated time
per_file
=
profile
.
map
do
|
file
,
lines
|
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
wall
=
summary
==
'exclusive'
?
excl
:
total
cpu
=
summary
==
'exclusive'
?
excl_cpu
:
total_cpu
cpu
=
summary
==
'exclusive'
?
excl_cpu
:
total_cpu
idle
=
summary
==
'exclusive'
?
(
excl
-
excl_cpu
)
:
(
total
-
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
,
file
,
lines
,
wall
,
cpu
,
idle
,
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
=
''
output
=
''
per_file
.
each
do
|
file_name
,
lines
,
file_wall
,
file_cpu
,
file_idle
,
file_sort
|
per_file
.
each
do
|
file_name
,
lines
,
file_wall
,
file_cpu
,
file_idle
,
file_sort
|
output
<<
"<div class='peek-rblineprof-file'><div class='heading'>"
output
<<
"<div class='peek-rblineprof-file'><div class='heading'>"
show_src
=
file_sort
>
min
show_src
=
file_sort
>
min
tmpl
=
show_src
?
"<a href='#' class='js-lineprof-file'>%s</a>"
:
"%s"
tmpl
=
show_src
?
"<a href='#' class='js-lineprof-file'>%s</a>"
:
"%s"
if
mode
==
'cpu'
output
<<
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
+
'/'
,
''
))
if
mode
==
'cpu'
else
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
+
'/'
,
''
))
output
<<
sprintf
(
"<span class='duration'>% 8.1fms</span>
#{
tmpl
}
"
,
file_wall
/
1000.0
,
file_name
.
sub
(
Rails
.
root
.
to_s
+
'/'
,
''
))
else
end
sprintf
(
"<span class='duration'>% 8.1fms</span>
#{
tmpl
}
"
,
file_wall
/
1000.0
,
file_name
.
sub
(
Rails
.
root
.
to_s
+
'/'
,
''
))
end
output
<<
"</div>"
# .heading
output
<<
"</div>"
# .heading
...
...
vendor/assets/javascripts/peek.js
浏览文件 @
e8591453
var
requestId
;
let
requestId
=
null
;
requestId
=
null
;
(
function
(
$
)
{
(
function
(
$
)
{
var
fetchRequestResults
,
getRequestId
,
peekEnabled
,
toggleBar
,
updatePerformanceBar
;
var
fetchRequestResults
,
getRequestId
,
peekEnabled
,
toggleBar
,
updatePerformanceBar
;
...
@@ -16,9 +14,11 @@ requestId = null;
...
@@ -16,9 +14,11 @@ requestId = null;
};
};
updatePerformanceBar
=
function
(
results
)
{
updatePerformanceBar
=
function
(
results
)
{
var
key
,
label
,
data
,
table
,
html
,
tr
,
duration_td
,
sql_td
,
strong
;
var
key
,
label
,
data
,
table
,
html
,
tr
,
duration_td
,
sql_td
,
strong
;
for
(
key
in
results
.
data
)
{
for
(
label
in
results
.
data
[
key
])
{
Object
.
keys
(
results
.
data
).
forEach
((
key
)
=>
{
Object
.
keys
(
results
.
data
[
key
]).
forEach
((
label
)
=>
{
data
=
results
.
data
[
key
][
label
];
data
=
results
.
data
[
key
][
label
];
if
(
label
==
'
queries
'
)
{
if
(
label
==
'
queries
'
)
{
table
=
document
.
createElement
(
'
table
'
);
table
=
document
.
createElement
(
'
table
'
);
...
@@ -40,12 +40,11 @@ requestId = null;
...
@@ -40,12 +40,11 @@ requestId = null;
table
.
className
=
'
table
'
;
table
.
className
=
'
table
'
;
$
(
"
[data-defer-to=
"
+
key
+
"
-
"
+
label
+
"
]
"
).
html
(
table
);
$
(
"
[data-defer-to=
"
+
key
+
"
-
"
+
label
+
"
]
"
).
html
(
table
);
}
}
else
{
else
{
$
(
"
[data-defer-to=
"
+
key
+
"
-
"
+
label
+
"
]
"
).
text
(
results
.
data
[
key
][
label
]);
$
(
"
[data-defer-to=
"
+
key
+
"
-
"
+
label
+
"
]
"
).
text
(
results
.
data
[
key
][
label
]);
}
}
}
}
);
}
}
);
return
$
(
document
).
trigger
(
'
peek:render
'
,
[
getRequestId
(),
results
]);
return
$
(
document
).
trigger
(
'
peek:render
'
,
[
getRequestId
(),
results
]);
};
};
toggleBar
=
function
(
event
)
{
toggleBar
=
function
(
event
)
{
...
@@ -77,19 +76,6 @@ requestId = null;
...
@@ -77,19 +76,6 @@ requestId = null;
};
};
$
(
document
).
on
(
'
keypress
'
,
toggleBar
);
$
(
document
).
on
(
'
keypress
'
,
toggleBar
);
$
(
document
).
on
(
'
peek:update
'
,
fetchRequestResults
);
$
(
document
).
on
(
'
peek:update
'
,
fetchRequestResults
);
$
(
document
).
on
(
'
pjax:end
'
,
function
(
event
,
xhr
,
options
)
{
if
(
xhr
!=
null
)
{
requestId
=
xhr
.
getResponseHeader
(
'
X-Request-Id
'
);
}
if
(
peekEnabled
())
{
return
$
(
this
).
trigger
(
'
peek:update
'
);
}
});
$
(
document
).
on
(
'
page:change turbolinks:load
'
,
function
()
{
if
(
peekEnabled
())
{
return
$
(
this
).
trigger
(
'
peek:update
'
);
}
});
return
$
(
function
()
{
return
$
(
function
()
{
if
(
peekEnabled
())
{
if
(
peekEnabled
())
{
return
$
(
this
).
trigger
(
'
peek:update
'
);
return
$
(
this
).
trigger
(
'
peek:update
'
);
...
...
vendor/assets/stylesheets/peek.scss
浏览文件 @
e8591453
...
@@ -6,16 +6,11 @@ header.navbar-gitlab.with-peek {
...
@@ -6,16 +6,11 @@ header.navbar-gitlab.with-peek {
}
}
#peek
{
#peek
{
background
:
#000
;
background
:
$black
;
height
:
35px
;
height
:
35px
;
line-height
:
35px
;
line-height
:
35px
;
color
:
#999
;
color
:
#999
;
.hidden
{
display
:
none
;
visibility
:
visible
;
}
&
.disabled
{
&
.disabled
{
display
:
none
;
display
:
none
;
}
}
...
@@ -58,12 +53,12 @@ header.navbar-gitlab.with-peek {
...
@@ -58,12 +53,12 @@ header.navbar-gitlab.with-peek {
}
}
strong
{
strong
{
color
:
#fff
;
color
:
$white-light
;
}
}
table
{
table
{
strong
{
strong
{
color
:
#000
;
color
:
$black
;
}
}
}
}
...
@@ -95,5 +90,5 @@ header.navbar-gitlab.with-peek {
...
@@ -95,5 +90,5 @@ header.navbar-gitlab.with-peek {
}
}
#modal-peek-pg-queries-content
{
#modal-peek-pg-queries-content
{
color
:
#000
;
color
:
$black
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录