Speed up integer reading from file in C++
I'm reading a file, line by line, and extracting integers from it. Some noteworthy points: the input file is not in binary; I cannot load up the whole file in memory; file format (only integers, separated by some delimiter): x1 x2 x3 x4 ... y1 y2 y3 ... z1 z2 z3 z4 z5 ... ... Just to add context , I'm reading the integers, and counting them, using an std::unordered_map<unsigned int, unsinged int> . Simply looping through lines, and allocating useless stringstreams, like this: std::fstream infile(<inpath>, std::ios::in); while (std::getline(infile, line)) { std::stringstream ss(line); } gives