title: Timing the CPU time of a python program?
body: <p>I would like to time a snippet of my code, and I would like just the CPU execution time (ignoring operating system processes etc).</p>
  
  <p>I've tried time.clock(), it appears too imprecise, and gives a different answer each time. (In theory surely if I run it again for the same code snippet it should return the same value??)</p>
  
  <p>I've played with timeit for about an hour. Essentially what kills it for me is the "setup" process, I end up having to import around 20 functions which is impractical as I'm practically just re-writing my code into the setup section to try and use it.</p>
  
  <p>Cprofiles are looking more and more attractive, but do they return CPU time? also, a minor point - it outputs way too much information. Is there any way to get the outputted information into a txt or .dat file so I can actually read it?</p>
  
  <p>Cheers</p>
  
  <p>OS: Ubuntu Program: python 2.7</p>