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
32eae963
Commit
32eae963
authored
Feb 06, 2020
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for Gitlab::Profiler.print_by_total_time
parent
f0897cb5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
spec/lib/gitlab/profiler_spec.rb
spec/lib/gitlab/profiler_spec.rb
+39
-0
No files found.
spec/lib/gitlab/profiler_spec.rb
View file @
32eae963
...
...
@@ -192,4 +192,43 @@ describe Gitlab::Profiler do
expect
(
described_class
.
log_load_times_by_model
(
null_logger
)).
to
be_nil
end
end
describe
'.print_by_total_time'
do
let
(
:stdout
)
{
StringIO
.
new
}
let
(
:output
)
do
stdout
.
rewind
stdout
.
read
end
let_it_be
(
:result
)
do
RubyProf
.
profile
do
sleep
0.1
1
.
to_s
end
end
before
do
stub_const
(
'STDOUT'
,
stdout
)
end
it
'prints a profile result sorted by total time'
do
described_class
.
print_by_total_time
(
result
)
total_times
=
output
.
scan
(
/^\s+\d+\.\d+\s+(\d+\.\d+)/
)
.
map
{
|
(
total
)
|
total
.
to_f
}
expect
(
output
).
to
include
(
'Kernel#sleep'
)
expect
(
total_times
).
to
eq
(
total_times
.
sort
.
reverse
)
expect
(
total_times
).
not_to
eq
(
total_times
.
uniq
)
end
it
'accepts a max_percent option'
do
described_class
.
print_by_total_time
(
result
,
max_percent:
50
)
expect
(
output
).
not_to
include
(
'Kernel#sleep'
)
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