print function is called many times.I want to calculate function's time.I wrote codes,
import timeit
class UserClass:
def callname(self):
print("HiTom")
if __name__ == '__main__':
def test():
user = UserClass()
user.callname()
test()
mtime = timeit.timeit(lambda: test())
print(mtime)
When I run the codes,"Hi Tom" is called many times. I really cannot understand why such a thing happens.
I rewrote
mtime = timeit.timeit(test(), number=1)
but ValueError: stmt is neither a string nor callable error happens.How can I make my ideal system?What is wrong in my codes?