Re: speed up calculation suggestions
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Tue, 13 Nov 2007 16:42:13 -0800
<rleavitt@xxxxxxxxxxxxxxxx> wrote:
I process many millions of records from text files through some fairly
simple calculations, and write out the results. I want to speed up this
process
I just seconds ago finished posting to another thread of someone writing
very general questions about optimization. It seems to be the subject of
the day. While the general advice there (look into improvement of
algorithms before code tweaks) is almost always applicable, you did
mention a term that sets off knee-jerk reactions.
That term is "text files". Text file I/O is notoriously slow - very
slow. My personal rough rule of thumb is that it is often about a factor
of 10 slower than unformatted I/O. That is just a rule of thumb and is
not precise at all, but it should serve to illustrate the "very slow". A
lot of this is from the conversion between text and internal numeric
forms.
If your calculations are "fairly simple", then the odds are high that
the run-time of your program could be dominated by the text file I/O.
Do the files *HAVE* to be text? Getting away from text is likely to save
a lot. If the same files are rocessed multiple times, it coudl well be
worthwhile to add a preprocessing step to first convert the text file
into an unformatted file; that way you only have to read the text file
once. Likewise, even if the input and final output files have to be text
for compatibility with other uses, one could make any intermediate files
unformatted.
There can sometimes be ways to somewhat speed up text file I/O, but that
gets into code tweaks (and is also likely to be at least somewhat
compiler dependent).
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: speed up calculation suggestions
- From: Carlie J. Coats
- Re: speed up calculation suggestions
- References:
- speed up calculation suggestions
- From: rleavitt
- speed up calculation suggestions
- Prev by Date: Re: How to Make F77 Program Faster (g95 compiler) ??
- Next by Date: Re: speed up calculation suggestions
- Previous by thread: Re: speed up calculation suggestions
- Next by thread: Re: speed up calculation suggestions
- Index(es):
Relevant Pages
|