edit: in sample code, stated printing console. sample code reference how doing file i/o. i'm storing data in vector used later.
so i'm using standard file i/o c++ read in csv file containing 7 million records. right takes 80 seconds on 8gb pc i'm want speed time.
string line; ifstream myfile ("example.csv"); if (myfile.is_open()) { while ( getline (myfile,line) ) { //cout << line << '\n'; -- edit. not printing out console storing array } myfile.close(); } since csv file has single column, there way grab of data @ once rather going through row row?
my understanding transfer file program takes longest thinking if store of data file somewhere(not sure of process exactly) , write @ once c++ program, should speed process.
getline going invoke block-based buffered reading on file stream, , os going further optimize access pattern pre-caching. (hell, hard drive going clever it.) it's not surprising program taking long, that's because console output lot slower file input (primarily because of need bunch of font rendering afterwards). before try optimize io, implement actual processing want perform on file [and take out console output], , see how fast then.
Comments
Post a Comment