What influences C++ I/O performance?



 DEVELOP > c-Plus-Plus > What influences C++ I/O performance?

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "SzH"
Date: 03 Feb 2008 08:04:39 AM
Object: What influences C++ I/O performance?
I would like to read in large integer matrices from text files, as
quickly as possible. I did a naive implementation (see below), but
for an input file with 100 rows and 250000 columns it runs more than
5x slower when compiled with visual studio express 2008 than the
version compiled with gcc 4.2.1 (mingw), on the same computer, same
OS.
I am not a regular C++ user. What are the things (relevant to the
standard C++ library) that influence the performance of I/O? I don't
believe that this is a "bug" in the VS compiler. It is more likely
that there are some relevant settings for iostreams (with a
significant impact on performance) that I am not aware of.
Any suggestions for making this program perform well portably would me
most welcome!
This is the relevant portion of the code:
std::ios::sync_with_stdio(false);
std::ifstream infile(path);
input_array arr(); // see note below
int row = 0, max_col = 0;
std::string line;
while (std::getline(infile, line)) {
std::istringstream ln(line);
int number;
int col = 0;
while (ln >> number) {
arr.append(number);
col++;
}
if (col != 0) {
if (row == 0)
max_col = col;
if (col != max_col) {
/*
* Array is not rectangular.
* Handle error (exit).
*/
}
row++;
}
}
Notes: 'input_array' is just a simple integer array, which grows
exponentially to accommodate new elements. It is not the source of
the performance problem.
Szabolcs
.

User: "Krice"

Title: Re: What influences C++ I/O performance? 03 Feb 2008 10:09:49 AM
On 3 helmi, 16:04, SzH <szhor...@gmail.com> wrote:

I am not a regular C++ user. What are the things (relevant to the
standard C++ library) that influence the performance of I/O?

Compiler optimization settings could be worth trying.
I guess VS has slower debug mode executables as well.
.
User: "SzH"

Title: Re: What influences C++ I/O performance? 03 Feb 2008 11:35:43 AM
On Feb 3, 5:09 pm, Krice <pau...@mbnet.fi> wrote:

On 3 helmi, 16:04, SzH <szhor...@gmail.com> wrote:

I am not a regular C++ user. What are the things (relevant to the
standard C++ library) that influence the performance of I/O?


Compiler optimization settings could be worth trying.
I guess VS has slower debug mode executables as well.

I forgot to mention that "release" mode was used with VS
(optimizations turned on). In "debug" mode, the program is twice as
slow, i.e. 10x as slow as with gcc. Whether optimizations are turned
on or not didn't really matter with gcc.
The VS timing was approx 80 seconds (in "release" mode), while the gcc
timing was about 15 seconds.
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER