Quote:What compiler are you using?
VS 2005 & vs 2008
So I went to my xp box and profiled and ended up with this:
Count %w/children time(us) void ArcASCIIRaster::threaded_parse::operator()(const tbb::blocked_range<unsigned int>& r) const 6 0.0 2.3 { 6 0.0 1.6 std::string* lines = m_lines; 6 0.0 1.6 bool* failure = m_failure; 6 0.0 1.5 std::string* msg = m_msg; 6 0.0 1.6 *failure = false; //contains the parsed numbers 6 0.0 2.2 std::vector<float> items; 6 0.0 663.3 items.reserve(m_cols); 6 0.0 1.9 for(unsigned int row = r.begin(); row < r.end(); row++) { //current col 5,866 0.0 1,492.7 unsigned int col = 0; parse(m_lines[row].begin(),m_lines[row].end(), //BEGIN GRAMMAR *space_p >> real_p[push_back_a(items)] >> *(+space_p >> real_p[push_back_a(items)]) >> *space_p //END GRAMMAR 5,866 10.2 186,285,532.9 ); //report an error 5,866 0.0 3,402.6 if(items.size() != m_cols) { *failure = true; *msg = "Not enough columns at line " + boost::lexical_cast<std::string>(row+1); return; } //need to chance to tbb:vector if we want to paralize this 5,866 0.0 1,591.4 for(unsigned int col = 0; col < items.size(); col++) { try 48,435,562 0.7 12,385,339.0 { 48,435,562 88.2 1,612,247,535.9 m_array[row*m_cols+col] = boost::lexical_cast<float>(items[col]); } catch(boost::bad_lexical_cast e) { *failure = true; *msg = "Failure to cast item to float"; return; } catch(...) { *failure = true; *msg = "Unkown error"; return; } } 5,866 0.0 8,223.5 items.clear(); 6 0.0 1.3 } 6 0.0 279.6 }
Third column is in microseconds after opening a 150mb file....
Culprit seems to be this awesomely redundant code (from an earlier version that was using strings)
1,612,247,535.9 m_array[row*m_cols+col] = boost::lexical_cast<float>(items[col]);
That is a full 26.8min worth of execution time. :( Remember this is a *slow* laptop and the profiler adds a little overhead. However I think it's clear where the problem is.
However, the Boost::Spirit call is still substantial - any ideas on how to reduce this down further?
However