1

I use the following way to get the execution time of main function ,

 from timeit import Timer
    t=Timer("main()","from __main__ import main")
    print t.timeit()

however,sometimes I need get return values of main function to decide whether main function should run once again or not. I don't know how to modify the code above to achieve the goal.
Any ideas?

Matt Elson
  • 4,177
  • 8
  • 31
  • 46
  • possible duplicate of [How can I capture return value with Python timeit module?](http://stackoverflow.com/questions/24812253/how-can-i-capture-return-value-with-python-timeit-module) – Crowman Sep 22 '14 at 04:16
  • "whether main function should run again or not": You do realize that the code above is already running `main()` 1,000,000 times, right? – chepner Sep 22 '14 at 04:41
  • The link(http://stackoverflow.com/questions/24812253/how-can-i-capture-return-value-with-python-timeit-module) is helpful, and t=Timer("main()","from \__main\__ import main") need also be modified into t=Timer(main,"from \__main\__ import main") at the same time, but I don't know why change the statement? – Matt Elson Sep 22 '14 at 07:51

0 Answers0