Does profiling remove some optimisations?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Mar 5 16:19:41 CET 2009


En Thu, 05 Mar 2009 07:39:20 -0200, andrew cooke <andrew at acooke.org>  
escribió:

> I have a core loop that is critical to performance.  The code is at
> http://www.acooke.org/lepl/api/lepl.parser-pysrc.html#trampoline
>
> If I write a separate "optimised" version of that function for when
> "monitor" is empty, with all the "if monitor" tests removed, the profiler
> (cProfile) indicates a 10% reduction in time spent in the loop.
>
> But if I run the same code 100 times under timeit, without profiling, I
> see no difference in total time.  The process is CPU bound.

How do you measure that? The profiler is able to isolate the time spent in  
your function, and the time spent in the remaining code. But timeit isn't.  
Perhaps the 10% reduction in trampoline() is minimized against the time  
spent in the rest of the code?

-- 
Gabriel Genellina




More information about the Python-list mailing list