473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Data redundancy, performance and formatted read/write operations.

I am starting to worry about the performance of formatted read/write
operations on data-redundant objects in my program.What can I do to improve
this performance should it become an issue?

Thanks.
Jul 23 '05 #1
6 2176
* Jason Heyes:
I am starting to worry about the performance of formatted read/write
operations on data-redundant objects in my program.What can I do to improve
this performance should it become an issue?


Measure.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #2
"Alf P. Steinbach" <al***@start.no> wrote in message
news:42****************@news.individual.net...
* Jason Heyes:
I am starting to worry about the performance of formatted read/write
operations on data-redundant objects in my program.What can I do to
improve
this performance should it become an issue?


Measure.


Whoops. I didn't expect a reply this short! :)
Jul 23 '05 #3
Jason Heyes wrote:
I am starting to worry about the performance of formatted read/write
operations on data-redundant objects in my program.What can I do to improve
this performance should it become an issue?

Thanks.

Here are some time-proven methods for speeding up I/O:
1. Don't perform I/O.

2. Reduce to the absolute minimum necessary.
Eliminate debug writes. Don't output the same data
twice or more. Etc.

3. Format all data then output it.
Format all of your data into a buffer, then output
that buffer. This eliminates the need to switch
back and forth between formatting and actual output.

4. Format only data that is necessary.
Minimize the text in formatted data requests. If
the text doesn't change, consider placing the text
into a buffer, then only format data into specific
locations. Then use block output on the whole buffer.

5. Use block input and output.
Generally, one call to output a lot of data is faster
than many calls to output small chunks of data.

6. Keep the stream continuous.
Some devices on the other end of the stream have
start-up or slow down overhead, but incur very
few penalties for processing data.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
Jul 23 '05 #4
"Thomas Matthews" <Th*************************@sbcglobal.net> wrote in
message news:bE*****************@newssvr17.news.prodigy.co m...
Here are some time-proven methods for speeding up I/O:
1. Don't perform I/O.

2. Reduce to the absolute minimum necessary.
Eliminate debug writes. Don't output the same data
twice or more. Etc.

3. Format all data then output it.
Format all of your data into a buffer, then output
that buffer. This eliminates the need to switch
back and forth between formatting and actual output.

4. Format only data that is necessary.
Minimize the text in formatted data requests. If
the text doesn't change, consider placing the text
into a buffer, then only format data into specific
locations. Then use block output on the whole buffer.

5. Use block input and output.
Generally, one call to output a lot of data is faster
than many calls to output small chunks of data.

6. Keep the stream continuous.
Some devices on the other end of the stream have
start-up or slow down overhead, but incur very
few penalties for processing data.


As a start, I am going to focus on (2). My task is to eliminate redundant
reads and writes in my program. It just so happens that all these operations
occur during the read or write operation of a single object. So I might use
the following functions to optimise my program:

std::istream &read_redundant(std::istream &is, Foo &foo)
{
if (!(is >> foo))
return is;
foo.add_duplicates();
return is;
}

std::ostream &write_redundant(std::ostream &os, Foo foo)
{
foo.remove_duplicates();
return os << foo;
}

The member functions Foo::add_duplicates and Foo::remove_duplicates must be
"inverses" of each other to make the optimisation process invisible to the
user.

Anyway. This is all up in the air. Thank you very much for your reply.
Jul 23 '05 #5
>I am starting to worry about the performance of formatted read/write
operations on data-redundant objects in my program.What can I do to improve
this performance should it become an issue?


Buffering
Binary Mode

SH
Jul 23 '05 #6

Thomas Matthews wrote:
Jason Heyes wrote:
I am starting to worry about the performance of formatted read/write operations on data-redundant objects in my program.What can I do to improve this performance should it become an issue?

Thanks.

Here are some time-proven methods for speeding up I/O:
1. Don't perform I/O.

2. Reduce to the absolute minimum necessary.
Eliminate debug writes. Don't output the same data
twice or more. Etc.

3. Format all data then output it.
Format all of your data into a buffer, then output
that buffer. This eliminates the need to switch
back and forth between formatting and actual output.

4. Format only data that is necessary.
Minimize the text in formatted data requests. If
the text doesn't change, consider placing the text
into a buffer, then only format data into specific
locations. Then use block output on the whole buffer.

5. Use block input and output.
Generally, one call to output a lot of data is faster
than many calls to output small chunks of data.

6. Keep the stream continuous.
Some devices on the other end of the stream have
start-up or slow down overhead, but incur very
few penalties for processing data.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library


And don't use endl at the end of lines, use "\n" instead. Most ostream
objects support buffered output, but endl will force the buffer to be
flushed. Using endl on every line can completely destroy all the
benefits of buffered output.

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
7
by: Matthias Czapla | last post by:
Hi! Whats the canonical way for handling raw data. I want to read a file without making any assumption about its structure and store portions of it in memory and compare ranges with constant...
13
by: Shailesh Humbad | last post by:
I wrote a short page as a quick reference to c++ integer data types. Any feedback welcome: http://www.somacon.com/blog/page11.php
0
by: Jason Heyes | last post by:
I would like to report formatted input operations that fail. To achieve this I write messages that reflect failed operations to std::cerr. For example, #include <iostream> #include <string> ...
13
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
5
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
5
by: pt | last post by:
Hi, i am wonderng what is faster according to accessing speed to read these data structure from the disk in c/c++ including alignment handling if we access it on little endian system 32 bits...
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.