Optimization is fun
Aug. 5th, 2008 10:30 pmIgnore unless you're a CS nerd :)
A friend of mine has a program that computes a funky number theoretical function. Unfortunately, it was taking 5 days to run. I volunteered to take a look at it, and managed to reduce the runtime to about 5 minutes by adding 14 characters to the code. Huzzah for optimization! As part of my investigations, I got yet another reminder that trying to guess where the slow bits are is pretty much useless. The actual culpit turned out to be that the math package she was using decided for some reason to use really really slow symbolic computations of floor() and ceil() instead of just using the built in versions. A couple of casts, and voila--a couple of orders of magnitude of improvement. But I would never have suspected that just by staring at the code.
A friend of mine has a program that computes a funky number theoretical function. Unfortunately, it was taking 5 days to run. I volunteered to take a look at it, and managed to reduce the runtime to about 5 minutes by adding 14 characters to the code. Huzzah for optimization! As part of my investigations, I got yet another reminder that trying to guess where the slow bits are is pretty much useless. The actual culpit turned out to be that the math package she was using decided for some reason to use really really slow symbolic computations of floor() and ceil() instead of just using the built in versions. A couple of casts, and voila--a couple of orders of magnitude of improvement. But I would never have suspected that just by staring at the code.
no subject
Date: 2008-08-06 01:47 pm (UTC)I think I'm missing something here. What did you do to find the problem besides stare at the code?
no subject
Date: 2008-08-06 03:47 pm (UTC)no subject
Date: 2008-08-07 01:40 am (UTC)no subject
Date: 2008-08-07 01:47 am (UTC)no subject
Date: 2008-08-07 07:14 am (UTC)That's just sick.
no subject
Date: 2008-08-07 10:27 am (UTC)no subject
Date: 2008-08-07 05:13 pm (UTC)