L
Lee
Hi,
I'm a stream virgin and am attempting to output strings to a file. My
approach is to write the string initially to a 'stringstream' and only when
complete write the stringstream to the file (ofstream).
The process works fine however appears to be rather slow. For example
outputting about 2Mb of data takes a couple of minutes (most of the time
appears to be writing to the stringstream) and as I'm creating several
hundred files in one run the whole time can run into hours. Oh, the files
are on my harddrive hence there is no network performance issues.
Is there anything basic I'm doing wrong (see code below) or does anyone have
any suggestions to improve this performance.
Thank in advance
Lee
stringstream m_outputFileReference;
ofstream m_outputFile ;
//initialisation for each file produced
m_outputFile.open(fullPathName, fstream:ut) ;
m_outputFileReference.str("") ;
m_outputFileReference.clear() ;
// output data using the format below
m_outputFileReference << CC_NUM_START_OPEN << tempStr << CC_NUM_START_CLOSE
;
when complete send the stringstream to the file
m_outputFile << m_outputFileReference.str()
m_outputFile.close();
I'm a stream virgin and am attempting to output strings to a file. My
approach is to write the string initially to a 'stringstream' and only when
complete write the stringstream to the file (ofstream).
The process works fine however appears to be rather slow. For example
outputting about 2Mb of data takes a couple of minutes (most of the time
appears to be writing to the stringstream) and as I'm creating several
hundred files in one run the whole time can run into hours. Oh, the files
are on my harddrive hence there is no network performance issues.
Is there anything basic I'm doing wrong (see code below) or does anyone have
any suggestions to improve this performance.
Thank in advance
Lee
stringstream m_outputFileReference;
ofstream m_outputFile ;
//initialisation for each file produced
m_outputFile.open(fullPathName, fstream:ut) ;
m_outputFileReference.str("") ;
m_outputFileReference.clear() ;
// output data using the format below
m_outputFileReference << CC_NUM_START_OPEN << tempStr << CC_NUM_START_CLOSE
;
when complete send the stringstream to the file
m_outputFile << m_outputFileReference.str()
m_outputFile.close();