can anyone offer performance tips to improve the running time ?
this function opens a file (a 7000 row by 30 col), and stores each elements in a matrix data . current running time is 4 sec, and i desperately need to minimize the running time as i need to iterate thru
thousands of such files please help, thanks
void iocsv(vector<vector<double> >& data, string path)
{
string s;
ifstream inFile;
inFile.open(path.c_str());
if (inFile) {
while (getline(inFile, s)) {
vector<double> col;
tokenizer<escaped_list_separator<char> > tok(s);
for (tokenizer<escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end(); ++beg) {
istringstream price;
price.str(*beg);
double x;
price >> x;
col.push_back(x);
}
data.push_back(col);
}
} else { cerr << "Warning: cannot open file " << path << endl;
cerr << "Program terminating ......" << endl; }
inFile.close();
}