Re: Faster way to write in a file



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
.



Relevant Pages

  • Re: Faster way to write in a file
    ... If the textual representation is being done by fprintf, ... the unconverted data in binary form is _much_ faster - and, ... A special-purpose double -> text conversion routine can provide a ...
    (comp.lang.c)
  • Re: Faster way to write in a file
    ... If the textual representation is being done by fprintf, writing ... the unconverted data in binary form is _much_ faster - and, ...
    (comp.lang.c)
  • Possible ToString() bug
    ... //Here I hand off the string to be used by another object ... can display a textual representation of d's value, then the ToString() ... into their repective data types. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: text reading
    ...     I'm not at all sure what ... "the textual representation of two..."). ... I chose that string because it matches a line in your ...
    (comp.lang.c)
  • Re: datetime problem
    ... A date string in accordance with the International Standard ISO 8601 can ... Which languages preclude compliance with ISO 8601? ...
    (comp.lang.perl.misc)