Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #10314
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: Best way to write the vector content to a file. |
| Date | Tue, 20 Sep 2011 15:37:04 +1200 |
| Lines | 25 |
| Message-ID | <9dqg31F76kU7@mid.individual.net> (permalink) |
| References | <31086262.1123.1316487944574.JavaMail.geo-discussion-forums@yqaa12> <19618014.1821.1316489291116.JavaMail.geo-discussion-forums@yqma37> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net cC524qjsATD3ksf/NHv1hQnTbVkLCKk9kVdFZUamatS7KXr1Xy |
| Cancel-Lock | sha1:guD1rp5pQnwEYaYWdN2nWu3QzIY= |
| User-Agent | Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 |
| In-Reply-To | <19618014.1821.1316489291116.JavaMail.geo-discussion-forums@yqma37> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:10314 |
Show key headers only | View raw
On 09/20/11 03:28 PM, sravanreddy001 wrote: Context is nice! > I'm actually writing this to a file. > But, file operation is just one simple write. > (the string that is constructed in the loop is written.. and the file size is around 5 MB.) > > but.. string+ = string + some_thing; > > if this is going to allocate a new memory location, then.. writing it multiple times to file.. will any of this approach help? > > One my i3 2nd gen computer.. it took around 10 mins. (using one single core) > not multithreaded. You would probably be better off just using an ofstream and writing a line at a time. I have one application that reads and writes in excess of 1GB with fstreams. Reading takes a couple of minutes, writing about 5. Your huge string will do a lot of progressively bigger memory moves, which are a bigger issue than the allocations. Kind of a macro-deoptimisation! -- Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:05 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 15:12 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:28 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 15:37 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:50 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 16:03 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:47 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 16:09 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:29 -0700
Re: Best way to write the vector content to a file. Juha Nieminen <nospam@thanks.invalid> - 2011-09-20 06:44 +0000
Re: Best way to write the vector content to a file. Goran <goran.pusic@gmail.com> - 2011-09-20 00:37 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 19:45 +1200
Re: Best way to write the vector content to a file. Goran <goran.pusic@gmail.com> - 2011-09-20 02:01 -0700
Re: Best way to write the vector content to a file. Rui Maciel <rui.maciel@gmail.com> - 2011-09-20 10:56 +0100
Re: Best way to write the vector content to a file. Fulvio Esposito <esposito.fulvio@gmail.com> - 2011-09-20 04:03 -0700
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-20 05:00 -0700
Re: Best way to write the vector content to a file. Goran <goran.pusic@gmail.com> - 2011-09-20 06:55 -0700
Re: Best way to write the vector content to a file. Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-20 13:39 -0500
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-20 17:50 -0700
csiph-web