|
Boost Users : |
From: Aljaz (aljaz.fajmut_at_[hidden])
Date: 2007-03-08 07:31:00
Hello..
I've been testing fstream libary to read a huge text file (45 megabytes),
which has around 2 million lines..
When I do (using fstream):
Code:
int line = 0;
string str;
ifstream is("file.txt");
while (!is.eof()) {
getline(is, str);
line++;
}It takes about 9 seconds to read the whole file..
If I open file it with any 'good' text editor (editplus, notepad++ for
instance) it takes a few seconds to read/load the whole file..
So I'm wondering.. What am I doing wrong?
What should I do to achieve that speed - better preformance?
Can boost::iostream do any better?
Another thing:
I tried writing data to deque (deque.pushback(str)) and was shocked on what
happened.. It took ages to process the file, cpu constant at 99% so I closed
the program after around 3 minutes..
Whats the 'proper' way to read files to memory? How do text editors do this?
They load the same file in 4 seconds!
I need a fastest way to read about 10 000 lines from text file at once..
Any help highly appreciated!
Best regards
A
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net