Hopefully I am doing something drastically wrong here, or perhaps this is normal.
I am trying to read from a file using a wifstream (it's a UTF-16 encoded file). The file contains roughly 24000 lines of text where the text is ~length of 6 wchar_t's each.
When performing the following statements, it takes about 2-3 seconds (by my observation) to complete:
I have tried:
wifstream file("text.txt");
wstringstream buffer;
buffer << file.rdbuf();
And:
wifstream file("text.txt");
wchar_t * buf = new wchar_t[fileSize];
file.read(buf, fileSize);
At first I thought it was due to the fileSize but thought "what the heck" and tried fopen:
FILE* f;
wchar_t * buf = new wchar_t[fileSize];
f = fopen("text.txt", "rb");
fread(buf, fileSize, 2, f);
I found that fopen reads in the entire file without any delays whatsoever(?!?!).
Anybody have a clue as to why I may be seeing such a huge degrade in performance using fstream?