next up previous contents Back To Software Index
Next: Background Information: How Up: Programming Guidelines Previous: When the Final

Optimizing Code for Maximum Processing Speed

CFITSIO has been carefully designed to obtain the highest possible speed when reading and writing FITS files. In order to achieve the best performance, however, application programmers must be careful to call the CFITSIO routines appropriately and in an efficient sequence; inappropriate usage of CFITSIO routines can greatly slow down the execution speed of a program.

The maximum possible I/O speed of CFITSIO depends of course on the type of computer system that it is running on. As a rough guide, the current generation of workstations can achieve speeds of 2 -- 10 MB/s when reading or writing FITS images and similar, or slightly slower speeds with FITS binary tables. Reading of FITS files can occur at even higher rates (30MB/s or more) if the FITS file is still cached in system memory following a previous read or write operation on the same file. To more accurately predict the best performance that is possible on any particular system, a diagnostic program called ``speed.c'' is included with the CFITSIO distribution which can be run to approximately measure the maximum possible speed of writing and reading a test FITS file.

The following 2 sections provide some background on how CFITSIO internally manages the data I/O and describes some strategies that may be used to optimize the processing speed of software that uses CFITSIO.