Re: Faster way to write in a file
- From: Morris Dovey <mrdovey@xxxxxxxx>
- Date: Wed, 13 Feb 2008 14:28:00 -0500
LilacSkin wrote:
On 13 fév, 15:13, Morris Dovey <mrdo...@xxxxxxxx> wrote:
Mark Bluemel wrote:
How does dumping the data in binary form compare to writing a
tab-delimited textual representation?
If the textual representation is being done by fprintf(), writing
the unconverted data in binary form is _much_ faster - and, of
course, may produce problems if there's a subsequent need to read
the data on a different machine.
A special-purpose double -> text conversion routine can provide a
fair amount of speed improvement. A real-world example was
developed in this CLC thread:
http://groups.google.com/group/comp.lang.c/browse_thread/thread/eb329...
(mind the wrap)
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USAhttp://www.iedu.com/DeSoto
Your idea is to use your "convert" function and to fwrite the
converted buffer ?
If yes, can I cast an long long in double to directly use it ?
You probably won't want to use _that_ convert function because it
does more than you want (double -> string) when you're really
wanting (long long -> string).
Just throw away the part that deals with the fractional part of
the double - and if all of your values are positive, throw away
the sign logic, too. That won't leave very much - and it
shouldn't waste many cycles.
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto
.
- Follow-Ups:
- Re: Faster way to write in a file
- From: LilacSkin
- Re: Faster way to write in a file
- References:
- Faster way to write in a file
- From: LilacSkin
- Re: Faster way to write in a file
- From: santosh
- Re: Faster way to write in a file
- From: Mark Bluemel
- Re: Faster way to write in a file
- From: Morris Dovey
- Re: Faster way to write in a file
- From: LilacSkin
- Faster way to write in a file
- Prev by Date: Re: Faster way to write in a file
- Next by Date: Re: Dereference an array pointer... UB?
- Previous by thread: Re: Faster way to write in a file
- Next by thread: Re: Faster way to write in a file
- Index(es):
Relevant Pages
|