Tue 01 Aug 2006

On the virtues of profiling

It's been said before that the key to optimising is profiling, but it bears repeating.

A common slowdown in my parsers is subseq, which is pretty wasteful. I had a parsing function that was taking 30 seconds to run, which was annoying me. “Ah, it's probably subseq!” I thought. Experience took over, though, and I profiled first… to find an uncompiled regular expression taking a huge amount of time, and consing an unnecessary 14MB. (CL-PPCRE usually compiles static string regular expressions at compile time, but this wasn't happening in this case, so there were over 3,000 calls to cl-ppcre::create-bmh-matcher at the top of the profile report.)

Fixing that with a simple let takes runtime down from 35 seconds to 1.5 seconds, putting our old friend subseq back in first place, where he belongs.

Posted at 2006-08-01 12:41:32 by RichardLink to On the virtues of …
Comments, trackbacks.

Google
Web holygoat.co.uk
  • richard is: