Commit 75d36215 authored by Shalabh Chaturvedi's avatar Shalabh Chaturvedi

Add pure-Python comparison doctest for profiling

parent 3826c4cb
...@@ -95,6 +95,28 @@ __doc__ = u""" ...@@ -95,6 +95,28 @@ __doc__ = u"""
>>> list(callees(s, 'genexpr')) >>> list(callees(s, 'genexpr'))
[] []
>>> def python_generator():
... yield 1
... yield 2
>>> def call_python_generator():
... list(python_generator())
>>> profile.runctx("call_python_generator()", locals(), globals(), statsfile)
>>> python_stats = pstats.Stats(statsfile)
>>> python_stats_dict = dict([(k[2], v[1]) for k,v in python_stats.stats.items()])
>>> profile.runctx("call_generator()", locals(), globals(), statsfile)
>>> cython_stats = pstats.Stats(statsfile)
>>> cython_stats_dict = dict([(k[2], v[1]) for k,v in cython_stats.stats.items()])
>>> python_stats_dict['python_generator'] == cython_stats_dict['generator']
True
>>> try:
... os.unlink(statsfile)
... except:
... pass
""" """
cimport cython cimport cython
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment