473,786 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2202
* 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.i ndividual.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.l earn.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************ *************@s bcglobal.net> wrote in
message news:bE******** *********@newss vr17.news.prodi gy.com...
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_duplica tes();
return is;
}

std::ostream &write_redundan t(std::ostream &os, Foo foo)
{
foo.remove_dupl icates();
return os << foo;
}

The member functions Foo::add_duplic ates and Foo::remove_dup licates 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.l earn.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
4537
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
3980
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 byte sequences. _I_ would read it into arrays of unsigned char and use C's memcmp(), but as you see Im a novice C++ programmer and think that theres some better, typically used, way. Regards
13
3694
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
971
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> class Foo { int a; int b;
13
2766
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 of C and I achieved that aim very early on. See, for example "The Design and Evolution of C++". -- Bjarne Stroustrup; http://www.research.att.com/~bs
5
8958
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 headers). I used ODBC in my VB.NET program to read that spreadsheet into a dataset, to make it easy to manipulate. The code I use to read it is as the bottom of this posting.
30
3405
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 commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on the dataset or connection? TIA
5
575
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 system + OS e.g. Windows, Linux, WinCE. I am not quite sure about the alignment of the memory.... soln. 1: should be faster, I am not sure. idx size (bytes) 1 4
10
8358
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 delivery of Travis Oliphant's NumPy manual, I have a quick question (hopefully) regarding how to read in Fortran written data. The data files are not binary, but ASCII text files with no formatting and mixed data types (strings, integers,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.