Gabriel Genellina wrote: > En Thu, 05 Mar 2009 07:39:20 -0200, andrew cooke <and...@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?
Yeah, I wasn't very clear, and when you do the maths it's borderline in the noise from the timeit results. Basically the argument is something like that routine was taking 1/10 of the total time, and I'd improved it by 10% so should see a 1% change in total speed. Which I thought I should be able to see (by using a large number of iterations in timeit). But really, worrying about a 1% total speedup is silly. I should be looking elsewhere. Which is good news, I guess, because having two versions of a core routine was a bit worrying. Cheers, Andrew -- http://mail.python.org/mailman/listinfo/python-list