test_profiling.py 399 B

12345678910111213141516171819202122
  1. '''
  2. '''
  3. import cProfile
  4. from math import sqrt
  5. def test():
  6. result = []
  7. for i in range(100000):
  8. x = sqrt(i)
  9. result.append(x)
  10. return result
  11. def main():
  12. result = test()
  13. for val in result:
  14. pass
  15. # cProfile.run('main()', 'results', 1)
  16. cProfile.run('main()', filename='my_result.txt', sort='nfl')
  17. cProfile.run('test()', filename='my_result.txt', sort='nfl')