"""Test suite for the profile module."""
from test
.test_support
import TESTFN
, vereq
# In order to have reproducible time, we simulate a timer in the global
# variable 'ticks', which represents simulated time in milliseconds.
# (We can't use a helper function increment the timer since it would be
# included in the profile and would appear to consume all the time.)
prof
= profile
.Profile(timer
)
prof
.runctx("testfunc()", globals(), globals())
# 1000 ticks total: 400 ticks local, 600 ticks in subfunctions
# 300 ticks total: 40 ticks local, 260 ticks in subfunctions
# 30 ticks total: 29 ticks local, 1 tick in subfunctions
# 50 ticks local: 39 ticks local, 11 ticks in subfunctions
# 10 ticks total: 8 ticks local, 2 ticks in subfunctions
def __getattr__(self
, name
):
profile
.runctx("testfunc()", d
, d
, TESTFN
)
profile
.runctx("testfunc2()", locals(), locals(), TESTFN
)
vereq(result
, [True, True])
if __name__
== "__main__":