Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
neoppod
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):
...
@@ -39,6 +39,13 @@ def defer(task):
app
.
em
.
wakeup
(
wrapper
)
app
.
em
.
wakeup
(
wrapper
)
break
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
=
'pdb'
if
IF
==
'pdb'
:
if
IF
==
'pdb'
:
# List of (module, callables) to break at.
# List of (module, callables) to break at.
...
@@ -135,19 +142,32 @@ elif IF == 'frames':
...
@@ -135,19 +142,32 @@ elif IF == 'frames':
write
(
"End of dump
\
n
"
)
write
(
"End of dump
\
n
"
)
elif
IF
==
'profile'
:
elif
IF
==
'profile'
:
DURATION
=
60
def
stop
(
prof
,
path
):
def
stop
(
prof
,
path
):
prof
.
disable
()
prof
.
disable
()
prof
.
dump_stats
(
path
)
prof
.
dump_stats
(
path
)
@
defer
@
defer
def
profile
(
app
):
def
profile
(
app
):
import
cProfile
,
threading
,
time
import
cProfile
,
threading
from
.lib.protocol
import
uuid_str
path
=
profile_path
(
app
)
path
=
'neo-%s-%s.prof'
%
(
uuid_str
(
app
.
uuid
),
time
.
time
())
prof
=
cProfile
.
Profile
()
prof
=
cProfile
.
Profile
()
threading
.
Timer
(
DURATION
,
stop
,
(
prof
,
path
)).
start
()
threading
.
Timer
(
PROFILE_
DURATION
,
stop
,
(
prof
,
path
)).
start
()
prof
.
enable
()
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'
:
elif
IF
==
'trace-cache'
:
from
struct
import
Struct
from
struct
import
Struct
from
.client.cache
import
ClientCache
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