Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
70a90e81
Commit
70a90e81
authored
Mar 31, 2011
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
profile nogil functions: warning instead of error
parent
58080275
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-2
tests/run/pstats_profile_test.pyx
tests/run/pstats_profile_test.pyx
+36
-0
No files found.
Cython/Compiler/Nodes.py
View file @
70a90e81
...
...
@@ -1252,9 +1252,10 @@ class FuncDefNode(StatNode, BlockNode):
preprocessor_guard
=
None
profile
=
code
.
globalstate
.
directives
[
'profile'
]
if
profile
and
lenv
.
nogil
:
warning
(
self
.
pos
,
"Cannot profile nogil function."
,
1
)
profile
=
False
if
profile
:
if
lenv
.
nogil
:
error
(
self
.
pos
,
"Cannot profile nogil function."
)
code
.
globalstate
.
use_utility_code
(
profile_utility_code
)
# Generate C code for header and body of function
...
...
tests/run/pstats_profile_test.pyx
View file @
70a90e81
...
...
@@ -20,6 +20,23 @@ __doc__ = u"""
KeyError: 'f_noprof'
>>> short_stats['f_raise']
100
>>> short_stats['withgil_prof']
100
>>> short_stats['withgil_noprof']
Traceback (most recent call last):
...
KeyError: 'withgil_noprof'
>>> short_stats['nogil_prof']
Traceback (most recent call last):
...
KeyError: 'nogil_prof'
>>> short_stats['nogil_noprof']
Traceback (most recent call last):
...
KeyError: 'nogil_noprof'
>>> try:
... os.unlink(statsfile)
... except:
...
...
@@ -43,6 +60,10 @@ def test_profile(long N):
n
+=
f_inline
(
i
)
n
+=
f_inline_prof
(
i
)
n
+=
f_noprof
(
i
)
n
+=
nogil_noprof
(
i
)
n
+=
nogil_prof
(
i
)
n
+=
withgil_noprof
(
i
)
n
+=
withgil_prof
(
i
)
try
:
n
+=
f_raise
(
i
+
2
)
except
RuntimeError
:
...
...
@@ -68,3 +89,18 @@ cdef int f_noprof(long a):
cdef
long
f_raise
(
long
)
except
-
2
:
raise
RuntimeError
@
cython
.
profile
(
False
)
cdef
int
withgil_noprof
(
long
a
)
with
gil
:
return
(
a
)
@
cython
.
profile
(
True
)
cdef
int
withgil_prof
(
long
a
)
with
gil
:
return
(
a
)
@
cython
.
profile
(
False
)
cdef
int
nogil_noprof
(
long
a
)
nogil
:
return
a
@
cython
.
profile
(
True
)
cdef
int
nogil_prof
(
long
a
)
nogil
:
return
a
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