Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
fd87e153
Commit
fd87e153
authored
Mar 27, 2023
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug: add an example to profile with yappi
parent
3f516cd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
neo/debug.py
neo/debug.py
+25
-5
No files found.
neo/debug.py
View file @
fd87e153
...
...
@@ -39,6 +39,13 @@ def defer(task):
app
.
em
.
wakeup
(
wrapper
)
break
PROFILE_DURATION
=
60
def
profile_path
(
app
):
import
time
from
.lib.protocol
import
uuid_str
return
'neo-%s-%s.prof'
%
(
uuid_str
(
app
.
uuid
),
time
.
time
())
IF
=
'pdb'
if
IF
==
'pdb'
:
# List of (module, callables) to break at.
...
...
@@ -135,19 +142,32 @@ elif IF == 'frames':
write
(
"End of dump
\
n
"
)
elif
IF
==
'profile'
:
DURATION
=
60
def
stop
(
prof
,
path
):
prof
.
disable
()
prof
.
dump_stats
(
path
)
@
defer
def
profile
(
app
):
import
cProfile
,
threading
,
time
from
.lib.protocol
import
uuid_str
path
=
'neo-%s-%s.prof'
%
(
uuid_str
(
app
.
uuid
),
time
.
time
())
import
cProfile
,
threading
path
=
profile_path
(
app
)
prof
=
cProfile
.
Profile
()
threading
.
Timer
(
DURATION
,
stop
,
(
prof
,
path
)).
start
()
threading
.
Timer
(
PROFILE_
DURATION
,
stop
,
(
prof
,
path
)).
start
()
prof
.
enable
()
elif
IF
==
'yappi'
:
import
thread
,
time
,
yappi
def
profile
():
path
=
profile_path
(
app
)
yappi
.
set_clock_type
(
"wall"
)
yappi
.
start
()
time
.
sleep
(
PROFILE_DURATION
)
yappi
.
stop
()
yappi
.
get_func_stats
().
save
(
path
,
'pstat'
)
yappi
.
clear_stats
()
assert
not
yappi
.
is_running
(),
"yappi already running"
for
app
in
app_set
():
thread
.
start_new_thread
(
profile
,
())
break
elif
IF
==
'trace-cache'
:
from
struct
import
Struct
from
.client.cache
import
ClientCache
...
...
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