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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Gwenaël Samain
cython
Commits
2b58df45
Commit
2b58df45
authored
Jul 20, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Profiling test
parent
a26379ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
tests/run/profile_test.pyx
tests/run/profile_test.pyx
+60
-0
No files found.
tests/run/profile_test.pyx
0 → 100644
View file @
2b58df45
__doc__
=
u"""
>>> import os, tempfile, cProfile as profile, pstats
>>> statsfile = tempfile.mkstemp()[1]
>>> profile.runctx("test_profile(100)", locals(), globals(), statsfile)
>>> s = pstats.Stats(statsfile)
>>> short_stats = dict([(k[2], v[1]) for k,v in s.stats.items()])
>>> short_stats['f_def']
100
>>> short_stats['f_cdef']
100
>>> short_stats['f_inline']
Traceback (most recent call last):
...
KeyError: 'f_inline'
>>> short_stats['f_inline_prof']
100
>>> short_stats['f_noprof']
Traceback (most recent call last):
...
KeyError: 'f_noprof'
>>> short_stats['f_raise']
100
>>> os.unlink(statsfile)
"""
cimport
cython
def
test_profile
(
long
N
):
cdef
long
i
,
n
=
0
for
i
from
0
<=
i
<
N
:
n
+=
f_def
(
i
)
n
+=
f_cdef
(
i
)
n
+=
f_inline
(
i
)
n
+=
f_inline_prof
(
i
)
n
+=
f_noprof
(
i
)
try
:
n
+=
f_raise
(
i
+
2
)
except
RuntimeError
:
pass
return
n
def
f_def
(
long
a
):
return
a
cdef
long
f_cdef
(
long
a
):
return
a
cdef
inline
long
f_inline
(
long
a
):
return
a
@
cython
.
profile
(
True
)
cdef
inline
long
f_inline_prof
(
long
a
):
return
a
@
cython
.
profile
(
False
)
cdef
int
f_noprof
(
long
a
):
return
a
cdef
long
f_raise
(
long
)
except
-
2
:
raise
RuntimeError
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