0

My Python code takes a long time to run(around 12 hours), is it possible to measure the cpu time it takes to run from its beginning to the end and also measure some part in the code in both Linux and Windows system?

The cluster I'm using is used by many other users, so I want to measure cpu time to see the time my code takes. Wall clock time is not accurate in my case. so I cannot use time.time().

From my understanding timeit module is not useful, as it works for a small snippet, please correct me if it's wrong. Is there any other module that I can use?

Any answer would be appreciate.

  • 1
    on unix, you can use the [`time` command](http://stackoverflow.com/questions/385408/get-program-execution-time-in-the-shell) in the shell to get such data – loopbackbee Jan 13 '14 at 17:17
  • Thank you for your response, @goncalopp. But I'm not quite familiar with using shell. I'll look into it. Do you have any idea about windows? – user2815916 Jan 15 '14 at 15:49
  • Not natively. You could try to install [cygwin](http://www.cygwin.com/) and also use `time`, but I have no idea how accurate it will be on windows. While on python over unix you can get away [using `time.clock` to measure CPU time](http://stackoverflow.com/a/85586/1595865), there [seems to exist no such alternative for windows, unless you're using python 3.3](http://stackoverflow.com/questions/15176619/timing-the-cpu-time-of-a-python-program) – loopbackbee Jan 15 '14 at 16:03
  • I just tried a simple test on cygwin, and `time` seems to return correct results – loopbackbee Jan 15 '14 at 16:09

0 Answers0