I would like to time a snippet of my code, and I would like just the CPU execution time (ignoring operating system processes etc).
I\'ve tried time.clock(), it appea
Instead of time.clock(), use timeit.default_timer(); it uses the most accurate option for your platform. For Ubuntu, for example, this will use time.time() instead.
When using timeit, create one setup function that you then can re-use for timeit. Yes, this looks like a bit of work but it ensures that you time what you really wanted to measure, and not include setup code in the time-critical measured section.