Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
surykatka
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
2
Merge Requests
2
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
surykatka
Commits
248f0619
Commit
248f0619
authored
May 18, 2021
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add profiler support to trace surykatka execution.
parent
284fb88f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
setup.py
setup.py
+4
-1
src/surykatka/cli.py
src/surykatka/cli.py
+26
-1
No files found.
setup.py
View file @
248f0619
...
...
@@ -49,6 +49,9 @@ setup(
"dev"
:
[
"pytest"
,
"black"
,
"pyflakes"
,
"mock"
,
"httpretty"
]
},
entry_points
=
{
"console_scripts"
:
[
"surykatka=surykatka.cli:runSurykatka "
]
"console_scripts"
:
[
"surykatka=surykatka.cli:runSurykatka "
,
"surykatkastat=surykatka.cli:runStats "
,
]
},
)
src/surykatka/cli.py
View file @
248f0619
...
...
@@ -55,6 +55,9 @@ from .bot import create_bot
default
=
"plain"
,
show_default
=
True
,
)
@
click
.
option
(
"--profile"
,
help
=
"Profiler data path"
,
type
=
click
.
Path
(
exists
=
False
)
)
def
runSurykatka
(
run
,
sqlite
,
...
...
@@ -65,6 +68,7 @@ def runSurykatka(
configuration
,
reload
,
output
,
profile
,
):
mapping
=
{}
...
...
@@ -85,7 +89,28 @@ def runSurykatka(
mapping
[
"RELOAD"
]
=
str
(
reload
)
mapping
[
"FORMAT"
]
=
output
bot
=
create_bot
(
cfgfile
=
configuration
,
mapping
=
mapping
)
return
bot
.
run
(
run
)
if
profile
is
None
:
return
bot
.
run
(
run
)
else
:
import
cProfile
return
cProfile
.
runctx
(
"bot.run(run)"
,
globals
(),
locals
(),
filename
=
profile
)
@
click
.
command
(
short_help
=
"Stats profiler bot data."
)
@
click
.
option
(
"--stats"
,
type
=
click
.
Choice
([
"cumul"
,
"time"
]))
@
click
.
argument
(
"profile"
,
type
=
click
.
Path
(
exists
=
True
,
dir_okay
=
False
))
def
runStats
(
stats
,
profile
):
click
.
echo
(
"Profile bot execution"
)
import
pstats
profile_stats
=
pstats
.
Stats
(
profile
)
if
stats
==
"time"
:
profile_stats
.
sort_stats
(
"time"
,
"calls"
).
print_stats
(
30
)
else
:
profile_stats
.
sort_stats
(
"cumulative"
).
print_stats
(
30
)
if
__name__
==
"__main__"
:
...
...
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