|
-
January 16th, 2008, 03:52 AM
#1
How to accelerate std::wofstream
I have the following code that performs writing into std::wofstream (with conversion into UTF-8):
std::wofstream stream;
stream.open(L"D:\\MyFile.txt", std::ios_base::app | std::ios_base::out);
std::locale utf8locale = <Get UTF-8 locale>;
stream.imbue(utf8locale);
int i;
for (i = 0; i < 700000; ++i)
{
stream.write(L"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 150);
}
stream.close();
This works too slowly — on computer P-4 3GHz the code (output file is 10 Mb) takes 4.1 sec.
Is it possible to accelerate it?
I have tried to large buffer for the stream (stream.rdbuf()->pubsetbuf(...)) — size of 200 Kb. But this gave no acceleration.
The compiler is MS Visual Studio 2005; Windows XP
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|