1 # cython: profile = True
4 >>> import os, tempfile, cProfile as profile, pstats
5 >>> statsfile = tempfile.mkstemp()[1]
6 >>> profile.runctx("test_profile(100)", locals(), globals(), statsfile)
7 >>> s = pstats.Stats(statsfile)
8 >>> short_stats = dict([(k[2], v[1]) for k,v in s.stats.items()])
9 >>> short_stats['f_def']
11 >>> short_stats['f_cdef']
13 >>> short_stats['f_inline']
15 >>> short_stats['f_inline_prof']
17 >>> short_stats['f_noprof']
18 Traceback (most recent call last):
21 >>> short_stats['f_raise']
24 ... os.unlink(statsfile)
30 if sys.version_info < (2,5):
31 # disable in earlier versions
33 >>> # nothing to test here ...
38 def test_profile(long N):
40 for i from 0 <= i < N:
55 cdef long f_cdef(long a):
58 cdef inline long f_inline(long a):
62 cdef inline long f_inline_prof(long a):
65 @cython.profile(False)
66 cdef int f_noprof(long a):
69 cdef long f_raise(long) except -2: