from petrel_client.utils.profile.profile import profileit @profileit(name='xxx',count= 500) def test(): import time time.sleep(0.001) return 1 l = [test() for _ in range(2000)] print('sum:', sum(l))