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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
3c545133
Commit
3c545133
authored
Dec 19, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests and formatting
parent
a8ebed60
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
7 deletions
+8
-7
lib/gitlab/metrics/influx_db.rb
lib/gitlab/metrics/influx_db.rb
+1
-0
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+1
-1
lib/gitlab/metrics/system.rb
lib/gitlab/metrics/system.rb
+0
-1
spec/lib/gitlab/metrics/method_call_spec.rb
spec/lib/gitlab/metrics/method_call_spec.rb
+6
-5
No files found.
lib/gitlab/metrics/influx_db.rb
View file @
3c545133
...
...
@@ -38,6 +38,7 @@ module Gitlab
# This is memoized since this method is called for every instrumented
# method. Loading data from an external cache on every method call slows
# things down too much.
# in milliseconds
@method_call_threshold
||=
settings
[
:method_call_threshold
]
end
...
...
lib/gitlab/metrics/method_call.rb
View file @
3c545133
...
...
@@ -72,7 +72,7 @@ module Gitlab
# Returns true if the total runtime of this method exceeds the method call
# threshold.
def
above_threshold?
real_time
>=
Metrics
.
method_call_threshold
real_time
_milliseconds
>=
Metrics
.
method_call_threshold
end
def
call_measurement_enabled?
...
...
lib/gitlab/metrics/system.rb
View file @
3c545133
...
...
@@ -55,7 +55,6 @@ module Gitlab
#
# Returns the time as a Float.
def
self
.
monotonic_time
Process
.
clock_gettime
(
Process
::
CLOCK_MONOTONIC
,
:float_second
)
end
end
...
...
spec/lib/gitlab/metrics/method_call_spec.rb
View file @
3c545133
...
...
@@ -8,7 +8,8 @@ describe Gitlab::Metrics::MethodCall do
it
'measures the performance of the supplied block'
do
method_call
.
measure
{
'foo'
}
expect
(
method_call
.
real_time
).
to
be_a_kind_of
(
Numeric
)
expect
(
method_call
.
real_time_seconds
).
to
be_a_kind_of
(
Numeric
)
expect
(
method_call
.
real_time_milliseconds
).
to
be_a_kind_of
(
Numeric
)
expect
(
method_call
.
cpu_time
).
to
be_a_kind_of
(
Numeric
)
expect
(
method_call
.
call_count
).
to
eq
(
1
)
end
...
...
@@ -84,13 +85,13 @@ describe Gitlab::Metrics::MethodCall do
end
it
'returns false when the total call time is not above the threshold'
do
expect
(
method_call
).
to
receive
(
:real_time
).
and_return
(
9
)
expect
(
method_call
).
to
receive
(
:real_time
_seconds
).
and_return
(
0.00
9
)
expect
(
method_call
.
above_threshold?
).
to
eq
(
false
)
end
it
'returns true when the total call time is above the threshold'
do
expect
(
method_call
).
to
receive
(
:real_time
).
and_return
(
9000
)
expect
(
method_call
).
to
receive
(
:real_time
_seconds
).
and_return
(
9
)
expect
(
method_call
.
above_threshold?
).
to
eq
(
true
)
end
...
...
@@ -131,7 +132,7 @@ describe Gitlab::Metrics::MethodCall do
describe
'#real_time'
do
context
'without timings'
do
it
'returns 0.0'
do
expect
(
method_call
.
real_time
).
to
eq
(
0.0
)
expect
(
method_call
.
real_time
_seconds
).
to
eq
(
0.0
)
end
end
...
...
@@ -139,7 +140,7 @@ describe Gitlab::Metrics::MethodCall do
it
'returns the total real time'
do
method_call
.
measure
{
'foo'
}
expect
(
method_call
.
real_time
>=
0.0
).
to
be
(
true
)
expect
(
method_call
.
real_time
_seconds
>=
0.0
).
to
be
(
true
)
end
end
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