Wed, 02 Jul 2003

Painless Optimization

Today, I was looking over a Delphi project which my company is close to marketing, trying to find a way to make it quicker when initially loading up the various settings (hundreds of them) from the INI files. The product functions as expected, and is fairly complete, so now is a good time to start looking at optimizations which will increase the number of calculations per second (one of Knuth's laws: premature optimization is the root of all evil).

I figured that the TINIFile object implemented by Delphi was merely a thin wrapper around the INI file related Windows API functions. I thought that I could perhaps write my own INI file object which would perhaps cache the file in memory, thus reducing disk I/O and hence, increasing performance. Checking out the source code for the TINIFile object confirmed my guesstimation, and provided a pleasant surprise as well. In the same INIFiles unit which defines the TINIFile object, another object called TMemINIFile is defined. The implementation of this class cached the INI file in memory, just as I had planned on doing.

To make a long story somewhat longer, I merely replaced references of TINIFile to TMemINIFile in all of the units where INI files are used, and the performace of the project increased by more than a factor of 8. Woo-hoo! Now that is the kind of optimization that I like...

posted at: 19:25 | path: /computers/programming | permanent link to this entry

Lunch Break Surf Report

In short: today, conditions at D street sucked golf balls through garden hoses. Not much in the way of waves as far as size, consistency, or shape are concerned. I was considering an AM session tomorrow, but I don't think I'll be getting out of bed at 4:30 for these kinds of conditions. Maybe on the 4th, however...

posted at: 19:20 | path: /surf | permanent link to this entry